index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <!-- <el-form-item label="部门ID" prop="deptId">
  5. <el-input v-model="queryParams.deptId" placeholder="请输入部门ID" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="项目编号" prop="projectId">
  8. <el-input v-model="queryParams.projectId" placeholder="请输入项目编号" clearable @keyup.enter.native="handleQuery" />
  9. </el-form-item> -->
  10. <!-- <el-form-item label="审核节点" prop="nodeOrder">
  11. <el-input
  12. v-model="queryParams.nodeOrder"
  13. placeholder="请输入审核节点"
  14. clearable
  15. @keyup.enter.native="handleQuery"
  16. />
  17. </el-form-item> -->
  18. <!-- <el-form-item label="审核人" prop="approver">-->
  19. <!-- <el-input v-model="queryParams.approver" placeholder="请输入审核人" clearable @keyup.enter.native="handleQuery" />-->
  20. <!-- </el-form-item>-->
  21. <!-- <el-form-item label="审核链" prop="chain">
  22. <el-input
  23. v-model="queryParams.chain"
  24. placeholder="请输入审核链"
  25. clearable
  26. @keyup.enter.native="handleQuery"
  27. />
  28. </el-form-item> -->
  29. <el-form-item>
  30. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  31. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  32. </el-form-item>
  33. </el-form>
  34. <el-row :gutter="10" class="mb8">
  35. <el-col :span="1.5">
  36. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  37. v-hasPermi="['system:config:add']">新增</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  41. v-hasPermi="['system:config:edit']">修改</el-button>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  45. v-hasPermi="['system:config:remove']">删除</el-button>
  46. </el-col>
  47. <!-- <el-col :span="1.5">
  48. <el-button
  49. type="warning"
  50. plain
  51. icon="el-icon-download"
  52. size="mini"
  53. @click="handleExport"
  54. v-hasPermi="['system:config:export']"
  55. >导出</el-button>
  56. </el-col> -->
  57. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
  60. <el-table-column type="selection" width="55" align="center" />
  61. <!-- <el-table-column label="id" align="center" prop="id" />-->
  62. <!-- <el-table-column label="部门ID" align="center" prop="deptId" />
  63. <el-table-column label="项目编号" align="center" prop="projectId" />-->
  64. <el-table-column label="审核顺序" align="center" prop="nodeOrder" />
  65. <el-table-column label="审核人" align="center" prop="userName" />
  66. <!-- <el-table-column label="审核链" align="center" prop="chain" /> -->
  67. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  68. <template slot-scope="scope">
  69. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  70. v-hasPermi="['system:config:edit']">修改</el-button>
  71. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  72. v-hasPermi="['system:config:remove']">删除</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  77. @pagination="getList" />
  78. <!-- 添加或修改审核配置对话框 -->
  79. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  80. <el-form ref="currentForm" :model="currentForm" :rules="rules" label-width="80px">
  81. <!--<el-form-item label="部门ID" prop="deptId">
  82. <el-input v-model="form.deptId" placeholder="请输入部门ID" :disabled="true" />
  83. </el-form-item>
  84. <el-form-item label="项目编号" prop="projectId">
  85. <el-input v-model="form.projectId" placeholder="请输入项目编号" :disabled="true" />
  86. </el-form-item>-->
  87. <el-form-item label="审核顺序" prop="nodeOrder">
  88. <el-input type="number" v-model="currentForm.nodeOrder" placeholder="请输入审核顺序" :disabled="false" />
  89. </el-form-item>
  90. <el-form-item label="审核人" prop="approver">
  91. <el-select v-model="currentForm.approver" multiple placeholder="请选择审核人" filterable >
  92. <el-option v-for="item in userList" :key="item.userId" :label="item.userName" :value="item.userId" />
  93. </el-select>
  94. <!-- <div style="display: flex; align-items: center; gap: 10px">
  95. <el-input v-model="form.approver" placeholder="请输入审核人" style="flex: 1" @focus="handleFocusUserInput" /> -->
  96. <!-- <el-button type="primary" @click="addApprover">新增</el-button>
  97. <el-button type="danger" @click="removeApprover" :disabled="!currentApprover">删除</el-button> -->
  98. <!-- </div> -->
  99. <!-- <div style="margin-top: 10px">
  100. <el-tag v-for="(approver, index) in this.approverOptions" :key="index" closable @close="handleCloseTag(approver)"
  101. style="margin-right: 10px; margin-bottom: 5px">
  102. {{ approver }}
  103. </el-tag>
  104. </div> -->
  105. </el-form-item>
  106. <!-- <el-form-item label="审核链" prop="chain">
  107. <el-input v-model="form.chain" placeholder="请输入审核链" :disabled="true" />
  108. </el-form-item> -->
  109. </el-form>
  110. <div slot="footer" class="dialog-footer">
  111. <el-button type="primary" @click="submitForm">确 定</el-button>
  112. <el-button @click="cancel">取 消</el-button>
  113. </div>
  114. </el-dialog>
  115. <el-dialog title="选择用户" :visible.sync="showUserDialog" width="500" append-to-body>
  116. <el-form :model="queryUserParams" ref="queryUserForm" size="small" :inline="true" v-show="showSearch"
  117. label-width="68px">
  118. <el-form-item label="用户名" prop="userName">
  119. <el-input v-model="queryUserParams.userName" placeholder="请输入用户名" clearable @keyup.enter.native="handleUserQuery" />
  120. </el-form-item>
  121. <el-form-item>
  122. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleUserQuery">搜索</el-button>
  123. </el-form-item>
  124. </el-form>
  125. <el-table :data="userList" style="width: 100%" @row-click="selectUser">
  126. <el-table-column prop="userId" label="用户ID"></el-table-column>
  127. <el-table-column prop="userName" label="用户名"></el-table-column>
  128. </el-table>
  129. <div class="pagination-container" style="margin-top: 15px">
  130. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  131. :current-page="queryUserParams.pageNum" :page-sizes="[10, 20, 30, 50]" :page-size="queryUserParams.pageSize"
  132. layout="total, sizes, prev, pager, next, jumper" :total="userTotal"></el-pagination>
  133. </div>
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import { listConfig, getConfig, delConfig, addConfig, updateConfig } from "@/api/system/auditConfig";
  139. import { listUser } from "@/api/system/user";
  140. export default {
  141. name: "Config",
  142. data() {
  143. return {
  144. // 遮罩层
  145. loading: true,
  146. // 选中数组
  147. ids: [],
  148. // 非单个禁用
  149. single: true,
  150. // 非多个禁用
  151. multiple: true,
  152. // 显示搜索条件
  153. showSearch: true,
  154. // 总条数
  155. total: 0,
  156. // 审核配置表格数据
  157. configList: [],
  158. // 弹出层标题
  159. title: "",
  160. // 是否显示弹出层
  161. open: false,
  162. // 查询参数
  163. queryParams: {
  164. pageNum: 1,
  165. pageSize: 10,
  166. deptId: null,
  167. projectId: null,
  168. // nodeOrder: null,
  169. approver: null,
  170. // chain: null,
  171. },
  172. currentForm:{
  173. nodeOrder:null,
  174. approver:null,
  175. },
  176. // 表单参数
  177. form: {
  178. },
  179. // 表单校验
  180. rules: {
  181. approver: [
  182. { required: true, message: '审核人不能为空', trigger: 'red' }
  183. ],
  184. nodeOrder: [
  185. { required: true, message: '审核顺序能为空', trigger: 'red'}
  186. ]
  187. },
  188. currentApprover: '', // Temporary input for new approver
  189. approverOptions: [], // List of available approvers
  190. showUserDialog: false,
  191. userList: [],
  192. userTotal: 0,
  193. queryUserParams: {
  194. pageNum: 1,
  195. pageSize: 10,
  196. username: null
  197. },
  198. list: [],
  199. appList: [],
  200. userTotal: 0,
  201. };
  202. },
  203. created() {
  204. this.getList();
  205. },
  206. methods: {
  207. handleFocusUserInput() {
  208. this.showUserDialog = true;
  209. this.getUserList();
  210. this.getList();
  211. },
  212. // 获取用户列表
  213. getUserList() {
  214. listUser(this.queryUserParams).then(response => {
  215. this.userList = response.rows;
  216. this.userTotal = response.total;
  217. });
  218. },
  219. handleUserQuery() {
  220. this.queryParams.pageNum = 1;
  221. this.getUserList();
  222. },
  223. resetUserQuery() {
  224. this.resetForm("queryUserParams");
  225. this.handleUserQuery();
  226. },
  227. handleUserQuery() {
  228. this.queryParams.pageNum = 1;
  229. this.getUserList();
  230. },
  231. // 分页大小变化
  232. handleSizeChange(val) {
  233. this.queryUserParams.pageSize = val;
  234. this.getUserList();
  235. },
  236. // 当前页变化
  237. handleCurrentChange(val) {
  238. this.queryUserParams.pageNum = val;
  239. this.getUserList();
  240. },
  241. // 选择用户
  242. selectUser(row) {
  243. this.form.approver = '';
  244. this.form.approver = row.userId;
  245. this.form.userName = row.userName;
  246. // this.userList.push({ userName: row.userName, userId: row.userId });
  247. this.showUserDialog = false;
  248. this.userList = [];
  249. },
  250. addApprover() {
  251. if (this.currentApprover && !this.approverOptions.includes(this.currentApprover)) {
  252. this.approverOptions.push(this.currentApprover);
  253. this.currentApprover = '';
  254. } else if (this.approverOptions.includes(this.currentApprover)) {
  255. this.$message.warning('该审核人已存在!');
  256. }
  257. },
  258. // 删除审核人
  259. removeApprover() {
  260. if (this.currentApprover) {
  261. const index = this.approverOptions.indexOf(this.currentApprover);
  262. if (index !== -1) {
  263. this.approverOptions.splice(index, 1);
  264. this.currentApprover = '';
  265. this.$message.success('删除成功!');
  266. } else {
  267. this.$message.warning('未找到该审核人!');
  268. }
  269. }
  270. },
  271. // 处理标签关闭
  272. handleCloseTag(approver) {
  273. const index = this.approverOptions.indexOf(approver);
  274. if (index !== -1) {
  275. this.approverOptions.splice(index, 1);
  276. this.$message.success('删除成功!');
  277. }
  278. },
  279. /** 查询审核配置列表 */
  280. getList() {
  281. this.loading = true;
  282. listConfig(this.queryParams).then(response => {
  283. this.configList = response.rows;
  284. this.total = response.total;
  285. this.loading = false;
  286. });
  287. },
  288. // 取消按钮
  289. cancel() {
  290. this.open = false;
  291. this.reset();
  292. },
  293. // 表单重置
  294. reset() {
  295. this.form = {
  296. id: null,
  297. deptId: null,
  298. projectId: null,
  299. nodeOrder: null,
  300. approver: [],
  301. chain: null,
  302. createBy: null,
  303. createTime: null,
  304. updateBy: null,
  305. updateTime: null
  306. };
  307. this.resetForm("form");
  308. },
  309. reset() {
  310. this.form = {
  311. userId: null
  312. };
  313. this.resetForm("queryUserForm");
  314. },
  315. /** 搜索按钮操作 */
  316. handleQuery() {
  317. this.queryParams.pageNum = 1;
  318. this.getList();
  319. },
  320. /** 重置按钮操作 */
  321. resetQuery() {
  322. this.resetForm("queryForm");
  323. this.handleQuery();
  324. },
  325. // 多选框选中数据
  326. handleSelectionChange(selection) {
  327. this.ids = selection.map(item => item.id)
  328. this.single = selection.length !== 1
  329. this.multiple = !selection.length
  330. },
  331. /** 新增按钮操作 */
  332. handleAdd() {
  333. this.reset();
  334. this.open = true;
  335. this.approverOptions = [];
  336. this.title = "添加审核配置";
  337. this.getUserList();
  338. },
  339. /** 修改按钮操作 */
  340. handleUpdate(row) {
  341. console.log('初始')
  342. this.reset();
  343. const id = row.id || this.ids
  344. // this.queryUserParams.userId = row.approver;
  345. this.approverOptions = [];
  346. this.getUserList();
  347. this.currentForm.approver = row.approverList;
  348. this.currentForm.nodeOrder = row.nodeOrder;
  349. this.currentForm.id = row.id;
  350. // getConfig(id).then(response => {
  351. // this.form = response.data;
  352. // this.approverOptions = this.form.approver.split(',');
  353. this.open = true;
  354. this.title = "修改审核配置";
  355. // });
  356. // this.queryUserParams.userId = '';
  357. },
  358. /** 提交按钮 */
  359. submitForm() {
  360. this.$refs["currentForm"].validate(valid => {
  361. if (valid) {
  362. // 创建表单副本,避免直接修改原始数据
  363. const submitForm = { ...this.currentForm };
  364. console.log("123123");
  365. // 如果 approval 是数组,转换为逗号分隔的字符串
  366. if (Array.isArray(submitForm.approver)) {
  367. submitForm.approver = submitForm.approver.join(',');
  368. }
  369. if (this.currentForm.id != null) {
  370. updateConfig(submitForm).then(response => {
  371. this.$modal.msgSuccess("修改成功");
  372. this.open = false;
  373. this.getList();
  374. });
  375. } else {
  376. addConfig(submitForm).then(response => {
  377. this.$modal.msgSuccess("新增成功");
  378. this.open = false;
  379. this.getList();
  380. });
  381. }
  382. }
  383. });
  384. },
  385. /** 删除按钮操作 */
  386. handleDelete(row) {
  387. const ids = row.id || this.ids;
  388. this.$modal.confirm('是否确认删除审核配置编号为"' + ids + '"的数据项?').then(function () {
  389. return delConfig(ids);
  390. }).then(() => {
  391. this.getList();
  392. this.$modal.msgSuccess("删除成功");
  393. }).catch(() => { });
  394. },
  395. /** 导出按钮操作 */
  396. handleExport() {
  397. this.download('system/config/export', {
  398. ...this.queryParams
  399. }, `config_${new Date().getTime()}.xlsx`)
  400. }
  401. }
  402. };
  403. </script>