business.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <div class="pageWrap bgc">
  3. <div class="content-warp flex-column-page-wrap">
  4. <!-- 公用搜索组件 -->
  5. <LeSearchForm ref="searchForm" v-model:searchData="searchData" :forms="forms" :loading="tableOpts.options.loading"> </LeSearchForm>
  6. <div style="margin: 20px; font-size: 1.2em; color: red">演示关联业务审批逻辑,对应 业务流程KEY为 purchaseOrder</div>
  7. <!-- LeTable 组件使用 -->
  8. <LeTable
  9. ref="tableRef"
  10. v-model:searchParams="tableOpts.searchParams"
  11. v-bind="tableOpts"
  12. v-model:curRow="tableOpts.curRow"
  13. v-model:checked-options="checkedColumns"
  14. :columns="activeColumns"
  15. >
  16. <template #toolLeft>
  17. <el-button type="primary" @click="addHandler">
  18. <el-icon class="btn-icon">
  19. <Plus />
  20. </el-icon>
  21. </el-button>
  22. <el-button type="danger" :disabled="curSelectionRows.length === 0" @click="batch_del">
  23. <el-icon class="btn-icon">
  24. <Delete />
  25. </el-icon>
  26. </el-button>
  27. </template>
  28. <template #statusSlot="scope">
  29. <el-tag v-if="scope.row.status === 1" type="warning">审批中</el-tag>
  30. <el-tag v-else-if="scope.row.status === 2" type="success">已通过</el-tag>
  31. <el-tag v-else-if="scope.row.status === 3" type="danger">已拒绝</el-tag>
  32. <el-tag v-else type="info">待审批</el-tag>
  33. </template>
  34. <template #actionSlot="scope">
  35. <div v-if="scope.row.status === 0">
  36. <el-tooltip content="提交审批" placement="bottom" effect="light">
  37. <el-icon class="ibt0" @click="submitProcessEv(scope.row)">
  38. <Promotion />
  39. </el-icon>
  40. </el-tooltip>
  41. <el-divider direction="vertical"></el-divider>
  42. <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row)">
  43. <template #reference>
  44. <el-icon class="ibt0">
  45. <Delete />
  46. </el-icon>
  47. </template>
  48. </el-popconfirm>
  49. </div>
  50. </template>
  51. </LeTable>
  52. </div>
  53. <LeFormConfigDialog
  54. v-if="visible"
  55. ref="dialogUserRef"
  56. v-model="visible"
  57. title="新增采购订单"
  58. width="600px"
  59. :form-data="activeData"
  60. :form-options="formOptions"
  61. @submit="submitHandler"
  62. />
  63. <!-- 设计表单 -->
  64. <business-launch v-if="drawerVisible" v-model="drawerVisible" :record="record"></business-launch>
  65. </div>
  66. </template>
  67. <script lang="tsx" setup>
  68. import BusinessLaunch from './businessLaunch.vue'
  69. import purchaseOrder from '@/api/test/purchaseOrder'
  70. import { progressBusinessApi } from '@/api/flow/process'
  71. import { computed, nextTick, ref, watch } from 'vue'
  72. import { ElMessage, ElMessageBox, ElTree } from 'element-plus'
  73. import { useTablePage } from '@/hooks/useTablePage'
  74. import { Plus, Delete } from '@element-plus/icons-vue'
  75. const drawerVisible = ref(false)
  76. const visible = ref(false) // 弹窗显示隐藏
  77. const activeData = ref({})
  78. const record = ref({})
  79. const formsDialog = [
  80. {
  81. prop: 'title',
  82. label: '标题',
  83. itemType: 'input',
  84. rules: [{ required: true, message: '请输入采购订单标题', trigger: 'blur' }]
  85. },
  86. {
  87. prop: 'content',
  88. label: '内容',
  89. rows: '2',
  90. type: 'textarea',
  91. rules: [{ required: true, message: '请输入采购订单内容', trigger: 'blur' }]
  92. }
  93. ]
  94. // 新增的表单 和 编辑的表单
  95. const formOptions = computed(() => {
  96. return {
  97. forms: formsDialog,
  98. labelWidth: 120,
  99. span: 30,
  100. showResetBtn: true,
  101. formConfig: {
  102. showCancelBtn: true,
  103. submitLoading: false
  104. }
  105. }
  106. })
  107. const groupFilterText = ref('')
  108. const treeRef = ref<InstanceType<typeof ElTree>>()
  109. // 表格搜索条件
  110. const forms = ref([
  111. {
  112. prop: 'keyword',
  113. label: '采购单名称:',
  114. itemType: 'input',
  115. placeholder: '请输入采购单名称'
  116. }
  117. ])
  118. // table列表数据请求
  119. const queryList = async () => {
  120. const { options, searchParams } = tableOpts
  121. options.loading = true
  122. try {
  123. const { records: list, total } = await purchaseOrder.postPageApi(searchParams)
  124. tableOpts.total = total
  125. tableOpts.list = list
  126. } catch {
  127. console.log('获取列表数据失败')
  128. tableOpts.total = 0
  129. tableOpts.list = []
  130. options.loading = false // 更改加载中的 loading值
  131. } finally {
  132. options.loading = false
  133. }
  134. }
  135. // table 参数
  136. const columns = [
  137. {
  138. prop: 'title',
  139. label: '标题',
  140. minWidth: 80
  141. },
  142. {
  143. prop: 'content',
  144. label: '内容',
  145. minWidth: 100
  146. },
  147. {
  148. prop: 'status',
  149. label: '状态',
  150. minWidth: 50,
  151. slots: {
  152. default: 'statusSlot'
  153. }
  154. },
  155. {
  156. prop: 'flwComment',
  157. label: '审批内容',
  158. minWidth: 100
  159. },
  160. {
  161. prop: 'createBy',
  162. label: '创建人',
  163. minWidth: 100
  164. },
  165. {
  166. prop: 'createTime',
  167. label: '创建时间',
  168. minWidth: 126
  169. },
  170. {
  171. prop: 'action',
  172. label: '操作',
  173. width: 100,
  174. fixed: 'right',
  175. slots: {
  176. default: 'actionSlot'
  177. }
  178. }
  179. ]
  180. const { searchData, tableOpts, checkedColumns, activeColumns, curSelectionRows, updateParams } = useTablePage(
  181. {
  182. options: {
  183. showIndex: false
  184. },
  185. // 需要展示的列
  186. columns,
  187. // 控制列配置
  188. columnsConfig: {
  189. columns
  190. }
  191. },
  192. {
  193. queryList,
  194. fetchImmediate: false
  195. }
  196. )
  197. // 删除
  198. const deleteItem = async ids => {
  199. // try {
  200. await purchaseOrder.postDeleteApi(ids)
  201. ElMessage.error(`删除成功~`)
  202. updateParams()
  203. // } catch (e) {
  204. // console.log('删除失败')
  205. // ElMessage.error(`删除失败~`)
  206. // }
  207. }
  208. // 单个删除
  209. const table_del = row => {
  210. deleteItem([row.id])
  211. }
  212. // 发起审批
  213. const submitProcessEv = async row => {
  214. const res = await progressBusinessApi()
  215. // const res1 = {
  216. // processId: '1808038047693168642',
  217. // processKey: 'qj',
  218. // processName: '请假申请',
  219. // processIcon: 'approval',
  220. // remark: '请假申请 V2',
  221. // categoryId: '1778232603034517506',
  222. // useScope: 0,
  223. // modelContent:
  224. // '{"name":"请假申请","key":"qj","instanceUrl":null,"nodeConfig":{"nodeName":"发起人","nodeKey":"flk1719904834757","callProcess":null,"actionUrl":null,"type":0,"setType":null,"nodeAssigneeList":[],"examineLevel":null,"directorLevel":null,"selectMode":null,"term":null,"termMode":null,"examineMode":null,"directorMode":null,"typeOfApprove":null,"passWeight":null,"conditionNodes":null,"remind":null,"allowSelection":null,"allowTransfer":null,"allowAppendNode":null,"allowRollback":null,"approveSelf":null,"extendConfig":null,"childNode":{"nodeName":"抄送人","nodeKey":"flk1719904831597","callProcess":null,"actionUrl":null,"type":2,"setType":null,"nodeAssigneeList":[],"examineLevel":null,"directorLevel":null,"selectMode":null,"term":null,"termMode":null,"examineMode":null,"directorMode":null,"typeOfApprove":null,"passWeight":null,"conditionNodes":null,"remind":null,"allowSelection":true,"allowTransfer":null,"allowAppendNode":null,"allowRollback":null,"approveSelf":null,"extendConfig":null,"childNode":{"nodeName":"条件路由","nodeKey":"flk1718359030676","callProcess":null,"actionUrl":null,"type":4,"setType":null,"nodeAssigneeList":null,"examineLevel":null,"directorLevel":null,"selectMode":null,"term":null,"termMode":null,"examineMode":null,"directorMode":null,"typeOfApprove":null,"passWeight":null,"conditionNodes":[{"nodeName":"条件1","nodeKey":"flk17183590306761","type":3,"priorityLevel":1,"conditionList":[[{"label":"a","field":"a","operator":"==","value":"1"}]],"childNode":{"nodeName":"延时处理","nodeKey":"flk1718359047245","callProcess":null,"actionUrl":null,"type":6,"setType":null,"nodeAssigneeList":null,"examineLevel":null,"directorLevel":null,"selectMode":null,"term":null,"termMode":null,"examineMode":null,"directorMode":null,"typeOfApprove":null,"passWeight":null,"conditionNodes":null,"remind":null,"allowSelection":null,"allowTransfer":null,"allowAppendNode":null,"allowRollback":null,"approveSelf":null,"extendConfig":{"time":"1:m"},"childNode":null,"parentNode":null,"parallelNodes":null,"delayType":null}},{"nodeName":"条件2","nodeKey":"flk17183590306762","type":3,"priorityLevel":2,"conditionList":[],"childNode":null}],"remind":null,"allowSelection":null,"allowTransfer":null,"allowAppendNode":null,"allowRollback":null,"approveSelf":null,"extendConfig":null,"childNode":{"nodeName":"审核人","nodeKey":"flk1716338897514","callProcess":null,"actionUrl":null,"type":1,"setType":3,"nodeAssigneeList":[{"tenantId":null,"id":"1492884198322536450","name":"财务总监","weight":null}],"examineLevel":1,"directorLevel":1,"selectMode":1,"term":0,"termMode":1,"examineMode":1,"directorMode":0,"typeOfApprove":1,"passWeight":null,"conditionNodes":null,"remind":false,"allowSelection":null,"allowTransfer":null,"allowAppendNode":null,"allowRollback":null,"approveSelf":0,"extendConfig":{"formConfig":[{"label":"人员","id":1716338743519,"opera":"1"},{"label":"请假类型","id":1716338807257,"opera":"1"},{"label":"日期","id":1716338768612,"opera":"1"},{"label":"原因","id":1716338745581,"opera":"1"}]},"childNode":null,"parentNode":null,"parallelNodes":null,"delayType":null},"parentNode":null,"parallelNodes":null,"delayType":null},"parentNode":null,"parallelNodes":null,"delayType":null},"parentNode":null,"parallelNodes":null,"delayType":null}}',
  225. // processForm:
  226. // '{"formStructure":{"list":[{"type":"inline","columns":[1716338743519],"style":{},"id":1716338743519,"key":"inline1716338743519"},{"type":"inline","columns":[1716338807257]},{"type":"inline","columns":[1716338768612]},{"type":"inline","columns":[1716338745581]}],"config":{"isSync":true,"pc":{"size":"default","labelPosition":"left","completeButton":{"text":"提交","color":"","backgroundColor":""}},"mobile":{"labelPosition":"left","completeButton":{"text":"提交","color":"","backgroundColor":""}}},"fields":[{"type":"select","label":"人员","icon":"employee","key":"select1716338743519","id":1716338743519,"options":{"dataKey":1716338743519,"filterable":true,"multiple":false,"defaultValue":"","placeholder":"请选择","labelWidth":100,"isShowLabel":true,"disabled":false,"clearable":true,"required":false,"renderType":2,"options":[{"value":"1778248547756670978","label":"test05"},{"value":"1778264912529981441","label":"test06"},{"value":"1778235567803465730","label":"test04"},{"value":"1778235419958444034","label":"test03"},{"value":"1778236021094481921","label":"test01"},{"value":"1778236187025342466","label":"test02"},{"value":"0","label":"admin"}]},"style":{"width":{"pc":"100%","mobile":"100%"}}},{"type":"select","label":"请假类型","icon":"dropdown0","key":"select1716338807257","id":1716338807257,"options":{"dataKey":1716338807257,"filterable":true,"multiple":false,"defaultValue":"","placeholder":"请选择","labelWidth":100,"isShowLabel":true,"disabled":false,"clearable":true,"required":false,"renderType":1},"style":{"width":{"pc":"100%","mobile":"50%"}}},{"type":"date","label":"日期","icon":"calendar","key":"date1716338768612","id":1716338768612,"options":{"isShowWordLimit":false,"clearable":true,"format":"YYYY-MM-DD","defaultValue":null,"startTime":null,"endTime":null,"placeholder":"请选择","labelWidth":100,"isShowLabel":true,"type":"date","required":false,"disabled":false},"style":{"width":{"pc":"100%","mobile":"100%"}}},{"type":"input","label":"原因","icon":"input","key":"input1716338745581","id":1716338745581,"options":{"clearable":true,"isShowWordLimit":false,"renderType":1,"disabled":false,"showPassword":false,"defaultValue":"","placeholder":"请输入","labelWidth":96,"isShowLabel":true,"required":false,"min":null,"max":null},"style":{"width":{"pc":"100%","mobile":"100%"}}}],"data":{"1716338743519":{"type":"select","list":[{"label":"Option1","value":"Zs-bVqTYdXkRjwIO3yh6L"},{"label":"Option2","value":"6ZEVueHFQmhnapsHGIzOh"},{"label":"Option3","value":"NBWpYD9GOT7mZTuSEvARr"}]},"1716338807257":{"type":"select","list":[{"label":"年","value":"0"},{"label":"病","value":"1"},{"label":"伤","value":"2"}]}},"logic":{}},"formData":{}}',
  227. // processSetting: {
  228. // allowRevocation: true,
  229. // allowRevocationDay: true,
  230. // allowUpdateDay: true,
  231. // allowDelegate: true,
  232. // allowBatchOperate: true,
  233. // secondOperatePrompt: true,
  234. // repeatOperateSkip: true
  235. // },
  236. // formTemplate: {
  237. // id: 0,
  238. // createId: 0,
  239. // createBy: 'string',
  240. // createTime: '2024-07-02T14:54:19.580Z',
  241. // updateBy: 'string',
  242. // updateTime: '2024-07-02T14:54:19.580Z',
  243. // tenantId: 'string',
  244. // formCategoryId: 0,
  245. // name: 'string',
  246. // code: 'string',
  247. // type: 0,
  248. // pcUrl: 'string',
  249. // appUrl: 'string',
  250. // content: 'string',
  251. // remark: 'string',
  252. // status: 0,
  253. // sort: 0
  254. // }
  255. // }
  256. const flag = Reflect.has(res, 'formTemplate')
  257. if (!flag) return
  258. if (res.formTemplate.type) {
  259. // vue自定义
  260. } else {
  261. record.value = { ...res, rowId: row.id}
  262. drawerVisible.value = true
  263. }
  264. }
  265. //批量删除
  266. const batch_del = () => {
  267. const ids = curSelectionRows.value.map(item => item.id) // 多选数据
  268. ElMessageBox.confirm('是否删除选中数据?', '提示', {
  269. confirmButtonText: '确认',
  270. cancelButtonText: '取消',
  271. type: 'error',
  272. buttonSize: 'default'
  273. }).then(() => {
  274. deleteItem(ids)
  275. })
  276. }
  277. // 弹窗事件
  278. const submitHandler = async params => {
  279. formOptions.value.formConfig.submitLoading = true
  280. try {
  281. params.status = params.status ? 1 : 0
  282. params.id = null
  283. await purchaseOrder.postAddOrEditSaveApi(params)
  284. ElMessage.success(`新增成功~`)
  285. visible.value = false
  286. updateParams()
  287. formOptions.value.formConfig.submitLoading = false
  288. } catch (e) {
  289. console.log(e)
  290. formOptions.value.formConfig.submitLoading = false
  291. }
  292. }
  293. const addHandler = () => {
  294. activeData.value = {}
  295. visible.value = true
  296. }
  297. nextTick(() => {
  298. queryList()
  299. })
  300. watch(groupFilterText, val => {
  301. treeRef.value!.filter(val)
  302. })
  303. </script>