index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. :table-loading="loading"
  12. @on-load="onLoad"
  13. @search-change="searchChange"
  14. @current-change="currentChange"
  15. @size-change="sizeChange"
  16. @refresh-change="refreshChange"
  17. @saveColumn="saveColumn"
  18. >
  19. <template slot-scope="scope" slot="status">
  20. <span v-if="scope.row.status == 'N'">新建</span>
  21. <span v-if="scope.row.status == 'A'">有效</span>
  22. <span v-if="scope.row.status == 'S'">停用</span>
  23. <span v-if="scope.row.status == 'Z'">暂存</span>
  24. </template>
  25. <template slot="menuLeft">
  26. <el-button
  27. type="primary"
  28. icon="el-icon-plus"
  29. size="small"
  30. @click.stop="addHandle"
  31. >创建单据</el-button>
  32. </template>
  33. <template slot-scope="scope" slot="menu">
  34. <el-button
  35. type="text"
  36. icon="el-icon-edit"
  37. size="small"
  38. @click.stop="editOpen(scope.row)"
  39. >编辑
  40. </el-button>
  41. <el-button
  42. type="text"
  43. icon="el-icon-delete"
  44. size="small"
  45. @click.stop="rowDel(scope.row, scope.index)"
  46. >删除
  47. </el-button>
  48. </template>
  49. </avue-crud>
  50. </basic-container>
  51. <el-dialog
  52. append-to-body
  53. :visible.sync="visible"
  54. width="80%"
  55. :close-on-click-modal="false"
  56. :destroy-on-close="true"
  57. :close-on-press-escape="false"
  58. v-dialog-drag
  59. :title="title"
  60. >
  61. <el-form :inline="true" :model="dataForm" :rules="dataRule" ref="dataForm">
  62. <el-form-item label="审核路径名称" prop="pathName">
  63. <el-input v-model="dataForm.pathName" placeholder="审核路径名称"></el-input>
  64. </el-form-item>
  65. <el-form-item label="状态" prop="status">
  66. <el-select v-model="dataForm.status" placeholder="状态" style="width: 100%">
  67. <el-option
  68. v-for="item in optionsStatue"
  69. :key="item.id"
  70. :label="item.name"
  71. :value="item.id">
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. <el-form-item label="维护人" prop="opUserName">
  76. <el-input v-model="dataForm.opUserName" disabled placeholder="维护人"></el-input>
  77. </el-form-item>
  78. <el-form-item label="维护时间" prop="opDate">
  79. <el-input v-model="dataForm.opDate" disabled placeholder="维护时间"></el-input>
  80. </el-form-item>
  81. <el-form-item label="类型名称" prop="businessType">
  82. <el-input v-model="dataForm.businessType" placeholder="类型名称"></el-input>
  83. </el-form-item>
  84. <el-form-item label="备注" class="full" prop="remarks">
  85. <el-input v-model="dataForm.remarks" placeholder="备注"></el-input>
  86. </el-form-item>
  87. </el-form>
  88. <avue-crud
  89. ref="dialogCrud"
  90. :option="detailOption"
  91. :data="detailData"
  92. >
  93. <template slot="levelName" slot-scope="{row,index}">
  94. <el-input
  95. v-model="row.levelName"
  96. clearable
  97. placeholder="请输入"
  98. ></el-input>
  99. </template>
  100. <template slot="remarks" slot-scope="{row,index}">
  101. <el-input
  102. v-model="row.remarks"
  103. clearable
  104. placeholder="请输入"
  105. ></el-input>
  106. </template>
  107. <template slot="iffixAuditUser" slot-scope="{row,index}">
  108. <el-select
  109. v-model="row.iffixAuditUser"
  110. >
  111. <el-option
  112. label="是"
  113. value="T"
  114. ></el-option>
  115. <el-option
  116. label="否"
  117. value="F"
  118. ></el-option>
  119. </el-select>
  120. </template>
  121. <template slot="iffinalItem" slot-scope="{row,index}">
  122. <el-select
  123. v-model="row.iffinalItem"
  124. >
  125. <el-option
  126. label="是"
  127. value="T"
  128. ></el-option>
  129. <el-option
  130. label="否"
  131. value="F"
  132. ></el-option>
  133. </el-select>
  134. </template>
  135. <template slot="userMold" slot-scope="{ row, index }">
  136. <el-select
  137. v-model="row.userMold"
  138. filterable
  139. placeholder="请选择规则"
  140. @change="userMoldChange(row)"
  141. >
  142. <el-option
  143. v-for="(item, index) in ruleData"
  144. :key="index"
  145. :value="item.value"
  146. :label="item.label"
  147. ></el-option>
  148. </el-select>
  149. </template>
  150. <template slot="auditMoldId" slot-scope="{ row, index }">
  151. <el-cascader
  152. v-model="row.auditMoldId"
  153. :disabled="!row.userMold || row.userMold == 3"
  154. :options="row.userMold == 1? roleData: row.userMold == 2? deptData: []"
  155. :props="props"
  156. collapse-tags
  157. clearable
  158. filterable
  159. @change="auditChange(row)"
  160. ></el-cascader>
  161. </template>
  162. <template slot="auditUserId" slot-scope="{row,index}">
  163. <el-select
  164. v-model="row.auditUserId"
  165. filterable
  166. collapse-tags
  167. multiple
  168. placeholder="审核人"
  169. >
  170. <el-option v-for="(item,index) in row.userList"
  171. :key="index"
  172. :label="item.realName"
  173. :value="item.id"
  174. ></el-option>
  175. </el-select>
  176. </template>
  177. <template slot="salesCompanyId" slot-scope="{row,index}">
  178. <el-select
  179. v-model="row.salesCompanyId"
  180. filterable
  181. collapse-tags
  182. placeholder="机构"
  183. >
  184. <el-option v-for="(item,index) in institutionList"
  185. :key="index"
  186. :label="item.deptName"
  187. :value="item.id"
  188. ></el-option>
  189. </el-select>
  190. </template>
  191. <template slot="menuLeft">
  192. <el-button
  193. type="primary"
  194. icon="el-icon-plus"
  195. size="small"
  196. @click.stop="addDetail"
  197. >新增</el-button>
  198. </template>
  199. <template slot-scope="{row,index}" slot="menu">
  200. <el-button
  201. type="text"
  202. icon="el-icon-delete"
  203. size="small"
  204. @click="rowDetailDelete(detailData, index)"
  205. >移除</el-button>
  206. </template>
  207. </avue-crud>
  208. <span slot="footer" class="dialog-footer">
  209. <el-button @click="closeDia">取消</el-button>
  210. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  211. </span>
  212. </el-dialog>
  213. </div>
  214. </template>
  215. <script>
  216. import option from "./config/mainList.json";
  217. import detailOption from "./config/detail.json";
  218. import { getList,
  219. modify,
  220. removeList,
  221. detailData ,userList,
  222. getUserApprovalList} from "@/api/approvalL/processConfig";
  223. import _ from "lodash";
  224. import {getDeptTree} from "@/api/system/dept";
  225. import {getRoleTree} from "@/api/system/role";
  226. import {topList} from "@/api/tirePartsMall/salesManagement/saleOrder";
  227. export default {
  228. name: "index",
  229. data() {
  230. return {
  231. institutionList: [],
  232. option: {},
  233. dataList: [],
  234. form: {},
  235. page: {
  236. pageSize: 10,
  237. currentPage: 1,
  238. total: 0,
  239. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  240. },
  241. detailData: [],
  242. auditUserIdDic:[],
  243. loading: false,
  244. search: {},
  245. visible: false,
  246. title: '',
  247. detailOption: {},
  248. optionsStatue: [
  249. {
  250. id: 'A',
  251. name: '有效'
  252. },
  253. {
  254. id: 'S',
  255. name: '停用'
  256. },
  257. ],
  258. dataForm: {
  259. status: 'A',
  260. },
  261. dataRule: {},
  262. tenantId: null, // 租户
  263. // dicData: [],
  264. props: {
  265. multiple: true,
  266. value: 'id',
  267. label: 'title',
  268. emitPath: false,
  269. },
  270. roleData: [],
  271. deptData: [],
  272. ruleData: [
  273. {value: 1, label: '角色'},
  274. {value: 2, label: '部门'},
  275. {value: 3, label: '用户'},
  276. ], //指定规则
  277. }
  278. },
  279. created() {
  280. this.option = option
  281. this.detailOption = detailOption
  282. getUserApprovalList().then(res =>{
  283. this.auditUserIdDic = res.data.data
  284. })
  285. this.tenantId = this.$store.getters.userInfo.tenant_id;
  286. getRoleTree(this.tenantId).then(res => {
  287. this.roleData = res.data.data;
  288. });
  289. getDeptTree(this.tenantId).then(res => {
  290. this.deptData = res.data.data;
  291. });
  292. let i = 0;
  293. this.option.column.forEach(item => {
  294. if (item.search) i++
  295. })
  296. if (i % 3 !== 0){
  297. const num = 3 - Number(i % 3)
  298. this.option.searchMenuSpan = num * 8;
  299. this.option.searchMenuPosition = "right";
  300. }
  301. },
  302. methods: {
  303. onLoad(page, params) {
  304. params = {
  305. ...params,
  306. current: page.currentPage,
  307. size: page.pageSize,
  308. }
  309. this.loading = true
  310. getList(params).then(res => {
  311. this.dataList = res.data.data.records ? res.data.data.records : [];
  312. }).finally(() => {
  313. this.loading = false
  314. })
  315. },
  316. addHandle() {
  317. this.title = '新增';
  318. this.visible = !this.visible
  319. this.dataForm = {}
  320. this.detailData = []
  321. },
  322. // 编辑
  323. editOpen(row) {
  324. topList().then(res => {
  325. this.institutionList = res.data.data
  326. })
  327. detailData({id: row.id}).then(res => {
  328. this.dataForm = res.data.data
  329. this.detailData = res.data.data.pjAuditPathsLevels
  330. this.detailData.map(e => {
  331. let params = {};
  332. if (e.auditMoldId && e.auditMoldId.length > 0) {
  333. if (e.userMold === 1) {
  334. this.$set(params, 'roleId', e.auditMoldId)
  335. } else if (e.userMold === 2) {
  336. this.$set(params, 'deptId', e.auditMoldId)
  337. }
  338. userList(params).then(response => {
  339. this.$set(e, 'userList', response.data.data);
  340. })
  341. } else {
  342. this.$set(e, 'userList', this.auditUserIdDic);
  343. }
  344. if (e.auditMoldId) {
  345. e.auditMoldId = e.auditMoldId.split(',')
  346. }
  347. if (e.auditUserId) {
  348. e.auditUserId = e.auditUserId.split(',')
  349. }
  350. })
  351. })
  352. this.title = '修改';
  353. this.visible = !this.visible
  354. },
  355. rowDel(row, index) {
  356. this.$confirm("确定将选择数据删除?", {
  357. confirmButtonText: "确定",
  358. cancelButtonText: "取消",
  359. type: "warning"
  360. }).then(() => {
  361. removeList(row.id).then(res =>{
  362. if(res.data.success){
  363. this.$message({
  364. type: "success",
  365. message: "操作成功!"
  366. });
  367. this.page.currentPage = 1;
  368. this.onLoad(this.page);
  369. }
  370. })
  371. })
  372. },
  373. //点击搜索按钮触发
  374. searchChange(params, done) {
  375. this.page.currentPage = 1;
  376. this.onLoad(this.page, params);
  377. done();
  378. },
  379. currentChange(val) {
  380. this.page.currentPage = val;
  381. },
  382. sizeChange(val) {
  383. this.page.currentPage = 1;
  384. this.page.pageSize = val;
  385. },
  386. refreshChange() {
  387. this.onLoad(this.page, this.search);
  388. },
  389. async saveColumn() {
  390. // const inSave = await this.saveColumnData(
  391. // this.getColumnName(50),
  392. // this.option
  393. // );
  394. if (inSave) {
  395. this.$message.success("保存成功");
  396. //关闭窗口
  397. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  398. }
  399. },
  400. addDetail() {
  401. if(this.detailData === undefined) {
  402. this.detailData = []
  403. }
  404. this.detailData.push({
  405. // userList: this.auditUserIdDic,
  406. // levelName: null,
  407. // auditUserId: [],
  408. // iffixAuditUser: 'T',
  409. // iffinalItem: 'T',
  410. // remarks: null,
  411. // $cellEdit: true
  412. })
  413. },
  414. rowDetailDelete(row, index) {
  415. row.splice(index, 1)
  416. },
  417. closeDia() {
  418. this.visible = false
  419. },
  420. dataFormSubmit() {
  421. if (this.detailData.length === 0) {
  422. this.$message.error('请维护审批级次')
  423. return false
  424. }
  425. for (let x in this.detailData) {
  426. if (this.detailData[x].iffixAuditUser === 'S') {
  427. if (this.detailData[x].auditUserId === null || this.detailData[x].auditUserId === '' || this.dataList[x].auditUserId.length === 0) {
  428. this.$message.error('请维护第' + (Number(x) + 1) + '级的审核人')
  429. return false
  430. }
  431. }
  432. }
  433. let params ={
  434. ...this.dataForm,
  435. pjAuditPathsLevels: JSON.parse(JSON.stringify(this.detailData))
  436. }
  437. for (let item of params.pjAuditPathsLevels){
  438. item.levelId = _.add(item.$index,1)
  439. delete item.id
  440. if (item.auditMoldId) {
  441. item.auditMoldId = item.auditMoldId.join(',');
  442. }
  443. if (item.auditUserId) {
  444. item.auditUserId = item.auditUserId.join(',');
  445. }
  446. }
  447. modify(params).then(res =>{
  448. if(res.data.success){
  449. this.$message.success("操作成功!")
  450. this.visible = false
  451. this.refreshChange()
  452. }
  453. })
  454. },
  455. auditChange(row) {
  456. let params = {};
  457. row.auditUserId = null;
  458. if (row.auditMoldId && row.auditMoldId.length > 0) {
  459. const data = row.auditMoldId.join(',');
  460. if (row.userMold === 1) {
  461. this.$set(params, 'roleId', data)
  462. } else if (row.userMold === 2) {
  463. this.$set(params, 'deptId', data)
  464. }
  465. userList(params).then(res => {
  466. this.$set(row, 'userList', res.data.data);
  467. // 选完角色部门默认全部带上
  468. this.$set(row, 'auditUserId', res.data.data.map(item => item = item.id));
  469. })
  470. } else {
  471. this.$set(row, 'userList', [])
  472. }
  473. },
  474. userMoldChange(row) {
  475. row.auditUserId = null;
  476. row.auditMoldId = null;
  477. this.$set(row, 'userList', row.userMold == 3? this.auditUserIdDic: []);
  478. },
  479. },
  480. }
  481. </script>
  482. <style scoped>
  483. </style>