list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div class="pageBody">
  3. <div class="titleBox">
  4. <div class="status flex-wrap">
  5. <el-radio v-model="radio" :label="item.id" v-for="(item, index) in option" :key="index">{{ item.label }}</el-radio>
  6. </div>
  7. <Search @getSearchData="getSearchData" @clearSearchData="clearSearchData" :isSlot="false">
  8. </Search>
  9. </div>
  10. <template v-if="listData.length">
  11. <div v-infinite-scroll="load" :infinite-scroll-distance="20" infinite-scroll-disabled="disabled" class="contantBox scrollbar">
  12. <div class="itemBox" v-for="(item, index) in listData" :key="index">
  13. <div v-is="['joblist_btn_del_job']" class="del" @click="delate(item.JobId,index)">
  14. <i class="el-icon-close"></i>
  15. </div>
  16. <div>
  17. <el-row>
  18. <el-col :span="24" class="nameBox">
  19. <div class="name">{{ item.JobName }}</div>
  20. <div v-is="['joblist_btn_edit']" class="loger" @click="toEdit(item.JobId)"></div>
  21. </el-col>
  22. </el-row>
  23. <el-row>
  24. <el-col :span="24"></el-col>
  25. </el-row>
  26. <el-row class="conntent" v-if="radio == 1">
  27. <el-col :span="12">上级组织:<span>{{ item.OrganName }}</span></el-col>
  28. <el-col :span="12">拥有职员:<span>{{ item.OfficerCount }}</span></el-col>
  29. <!-- <el-col :span="12" class="flexLeft">权限项数:<span>{{ item.AuthCount }}</span></el-col> -->
  30. </el-row>
  31. <!-- <el-row class="conntent" v-if="radio == 1">
  32. <el-col :span="24">拥有职员:<span>{{ item.OfficerCount }}</span></el-col>
  33. </el-row> -->
  34. <el-row class="conntent2" v-if="radio == 2">
  35. <el-col :span="24"><span>{{ item.UpLink }}</span></el-col>
  36. </el-row>
  37. <el-row class="conntent">
  38. <el-col :span="12">
  39. 状态:<span class="used" v-if="item.Status == 1">启用</span>
  40. <span class="unUsed" v-else-if="item.Status == 0">停用</span>
  41. </el-col>
  42. <el-col v-is="['joblist_btn_state_swatch']" :span="12" class="flexLeft">
  43. <el-switch @change="isUsedChange(item, index)" v-model="item.Flag" :active-value="true" :inactive-value="false" active-color="#6F81BC" inactive-color="#CFD6E2">
  44. </el-switch>
  45. </el-col>
  46. </el-row>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <template v-else>
  52. <el-empty style="padding-top:150px;" description="暂无数据"></el-empty>
  53. </template>
  54. <template v-if="total > 1">
  55. <p class="center" v-if="loading">加载中...</p>
  56. <p class="center" v-if="noMore">没有更多数据了~</p>
  57. </template>
  58. <Dialog :flag="dialogVisible">
  59. <div class="closeDialog">
  60. <div class="title">删除岗位</div>
  61. <div class="content">是否确定要删除该岗位?</div>
  62. <div class="foot right t30">
  63. <el-button size="medium" type="danger" class="r24" @click="del()">删除</el-button>
  64. <el-button size="medium" @click="dialogVisible = false">取消</el-button>
  65. </div>
  66. </div>
  67. </Dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import Search from "@/layout/components/Search";
  72. import Dialog from "@/layout/components/Dialog";
  73. import { GetJobList, ChangeJobStatus, DeleteJob } from "@/api/jobApi";
  74. export default {
  75. data () {
  76. return {
  77. dialogVisible: false,
  78. GroupUpid: "",
  79. serachinfo: "", //搜索内容
  80. delId: "",//删除项ID
  81. listData: [], //列表数据
  82. radio: 1,
  83. option: [
  84. {
  85. label: "信息概览",
  86. id: 1,
  87. },
  88. {
  89. label: "组织路径",
  90. id: 2,
  91. },
  92. ],
  93. pageSize: 20,
  94. pageNum: 1,
  95. total: '',
  96. loading: false,
  97. dataList: [],
  98. index: null
  99. };
  100. },
  101. components: { Search, Dialog },
  102. created () {
  103. if (this.$route.query.keyWords) {
  104. this.serachinfo = this.$route.query.keyWords;
  105. }
  106. this.AccountList({
  107. QueryName: this.serachinfo,
  108. PageSize: this.pageSize,
  109. PageIndex: this.pageNum
  110. });
  111. },
  112. computed: {
  113. noMore () {
  114. return this.pageNum >= this.total;
  115. },
  116. disabled () {
  117. return this.loading || this.noMore;
  118. }
  119. },
  120. methods: {
  121. //查询
  122. getSearchData (val) {
  123. this.listData = [];
  124. this.dataList = [];
  125. this.pageNum = 1;
  126. this.serachinfo = val;
  127. this.AccountList({
  128. QueryName: this.serachinfo,
  129. PageSize: this.pageSize,
  130. PageIndex: this.pageNum
  131. });
  132. },
  133. //清除查询
  134. clearSearchData () {
  135. this.listData = [];
  136. this.dataList = [];
  137. this.pageNum = 1;
  138. this.serachinfo = '';
  139. this.AccountList({
  140. QueryName: this.serachinfo,
  141. PageSize: this.pageSize,
  142. PageIndex: this.pageNum
  143. });
  144. },
  145. //修改状态
  146. async isUsedChange (value, index) {
  147. let item = _.cloneDeep(value);
  148. const { JobId, Flag } = item
  149. const Status = Flag ? 1 : 0
  150. try {
  151. let data = null;
  152. let str = "";
  153. if (item.Flag == false) {
  154. data = {
  155. JobId: item.JobId,
  156. Status: 0,
  157. };
  158. str = "停用" + item.JobName + "成功";
  159. } else {
  160. data = {
  161. JobId: item.JobId,
  162. Status: 1,
  163. };
  164. str = "启用" + item.JobName + "成功";
  165. }
  166. ChangeJobStatus(data).then((result) => {
  167. if (result.code == 0) {
  168. this.$message.success(str);
  169. this.listData.forEach(item => {
  170. if (item.JobId == JobId) {
  171. item.Flag = Flag
  172. item.Status = Status
  173. }
  174. })
  175. }
  176. });
  177. } catch (error) {
  178. this.$message.error("操作" + item.JobName + "失败");
  179. item.Flag = !item.Flag;
  180. this.listData[index] = _.cloneDeep(item);
  181. console.log("出错了", error);
  182. }
  183. },
  184. delate (id, index) {
  185. this.dialogVisible = true;
  186. this.delId = id;
  187. this.index = index;
  188. },
  189. toEdit (id) {
  190. this.$router.push({
  191. path: "jobs/edit",
  192. query: { JobId: id },
  193. });
  194. },
  195. //获取列表
  196. async AccountList (obj) {
  197. try {
  198. this.loading = true;
  199. const result = await GetJobList(obj);
  200. if (result.code === 0) {
  201. const datas = result.returnData.records;
  202. datas.forEach((element, index) => {
  203. if (element.Status == 1) {
  204. element["Flag"] = true;
  205. } else {
  206. element["Flag"] = false;
  207. }
  208. datas[index] = element;
  209. });
  210. this.dataList.push(datas);
  211. const arrs = this.dataList.flat();
  212. const msgs = _.unionBy(arrs, "JobId");
  213. this.listData = msgs;
  214. this.total = result.returnData.pages;
  215. this.loading = false;
  216. } else {
  217. this.$message.error(result.message);
  218. this.loading = false;
  219. }
  220. } catch (error) {
  221. console.log("出错了", error);
  222. this.loading = false;
  223. }
  224. },
  225. //删除接口
  226. async del () {
  227. try {
  228. const result = await DeleteJob({
  229. JobId: this.delId,
  230. });
  231. if (result.code === 0) {
  232. this.dialogVisible = false;
  233. this.$message.success(result.message);
  234. this.listData.splice(this.index, 1);
  235. this.index = null
  236. }
  237. } catch (error) {
  238. this.dialogVisible = false;
  239. // this.$message.error("删除失败");
  240. console.log("出错了", error);
  241. }
  242. },
  243. //滚动加载数据
  244. load () {
  245. this.pageNum += 1;
  246. this.AccountList({
  247. QueryName: this.serachinfo,
  248. PageSize: this.pageSize,
  249. PageIndex: this.pageNum
  250. });
  251. }
  252. },
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. .pageBody {
  257. width: 100%;
  258. padding: 0 64px;
  259. position: relative;
  260. .titleBox {
  261. position: fixed;
  262. width: 100%;
  263. padding: 30px 64px;
  264. padding-left: 156px;
  265. left: 0;
  266. display: flex;
  267. flex-direction: row;
  268. justify-content: space-between;
  269. background: #f5f7fa;
  270. z-index: 100;
  271. .addBtn {
  272. width: 120px;
  273. height: 48px;
  274. background: #f5f7fa;
  275. border: 1px solid #b4b7cb;
  276. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  277. border-radius: 6px;
  278. font-size: 16px;
  279. font-weight: bold;
  280. color: #6f81bc;
  281. }
  282. .status {
  283. align-items: center;
  284. & > div {
  285. margin-right: 28px;
  286. .icon {
  287. width: 16px;
  288. height: 16px;
  289. background: #6f81bc;
  290. border-radius: 2px;
  291. display: inline-block;
  292. vertical-align: middle;
  293. margin-right: 10px;
  294. position: relative;
  295. top: -2px;
  296. }
  297. &:last-child {
  298. margin-right: 0;
  299. }
  300. }
  301. .status2 {
  302. .icon {
  303. background: #f25555;
  304. }
  305. }
  306. .status3 {
  307. .icon {
  308. background: #cfd6e2;
  309. }
  310. }
  311. }
  312. }
  313. .contantBox {
  314. padding-top: 110px;
  315. display: flex;
  316. flex-direction: row;
  317. flex-wrap: wrap;
  318. justify-content: flex-start;
  319. width: calc(100% + 10px);
  320. height: 79vh;
  321. overflow-y: auto;
  322. overflow-x: hidden;
  323. .itemBox {
  324. width: calc(25% - 20px);
  325. margin: 10px;
  326. position: relative;
  327. padding: 23px 32px;
  328. background: #ffffff;
  329. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  330. border-radius: 16px;
  331. overflow: hidden;
  332. max-height: 200px;
  333. .headLine {
  334. width: 100%;
  335. height: 4px;
  336. background: #f25555;
  337. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  338. border-radius: 16px;
  339. position: absolute;
  340. left: 0;
  341. top: 0;
  342. }
  343. .onlneHead {
  344. background: #6f81bc;
  345. width: 100%;
  346. height: 4px;
  347. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  348. border-radius: 16px;
  349. position: absolute;
  350. left: 0;
  351. top: 0;
  352. }
  353. .onlneHead2 {
  354. background: #cfd6e2;
  355. width: 100%;
  356. height: 4px;
  357. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  358. border-radius: 16px;
  359. position: absolute;
  360. left: 0;
  361. top: 0;
  362. }
  363. .el-row {
  364. margin: 8px 0;
  365. }
  366. .flexLeft {
  367. display: flex;
  368. justify-content: flex-end;
  369. flex-direction: row;
  370. }
  371. .del {
  372. position: absolute;
  373. right: 24px;
  374. top: 32px;
  375. cursor: pointer;
  376. z-index: 1;
  377. }
  378. .nameBox {
  379. display: flex;
  380. .name {
  381. font-size: 18px;
  382. font-weight: bold;
  383. color: #303133;
  384. width: 150px;
  385. white-space: nowrap;
  386. overflow: hidden;
  387. text-overflow: ellipsis;
  388. }
  389. .loger {
  390. width: 24px;
  391. height: 24px;
  392. background: url("../../assets/status/ic_edit.png") no-repeat;
  393. background-size: 100% 100%;
  394. border: 1px solid #e4e7ec;
  395. border-radius: 50%;
  396. margin-left: 24px;
  397. cursor: pointer;
  398. }
  399. .loger:hover {
  400. background: url("../../assets/status/ic_edit_hovar.png") no-repeat;
  401. background-size: 100% 100%;
  402. }
  403. }
  404. .conntent {
  405. margin-top: 14px;
  406. }
  407. .conntent2 {
  408. margin-top: 14px;
  409. height: 40px;
  410. word-break: break-all;
  411. text-overflow: ellipsis;
  412. display: -webkit-box;
  413. -webkit-box-orient: vertical;
  414. -webkit-line-clamp: 2;
  415. overflow: hidden;
  416. }
  417. .used {
  418. font-size: 16px;
  419. font-weight: 400;
  420. color: #6f81bc;
  421. }
  422. span {
  423. font-size: 16px;
  424. font-weight: 400;
  425. color: #909399;
  426. }
  427. }
  428. }
  429. }
  430. </style>