index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="工序名称" name="processName">
  7. <a-input v-model:value="searchFormState.processName" placeholder="查询工序名称" allow-clear />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-button type="primary" @click="tableRef.refresh()">查询</a-button>
  12. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  13. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizProcessAdd')">
  14. <template #icon><plus-outlined /></template>
  15. 新增
  16. </a-button>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </a-card>
  21. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  22. <s-table
  23. ref="tableRef"
  24. :columns="columns"
  25. :data="loadData"
  26. bordered
  27. :row-key="(record) => record.id"
  28. >
  29. <template #bodyCell="{ column, record, index }">
  30. <template v-if="column.dataIndex === 'serial'">
  31. {{ index + 1 }}
  32. </template>
  33. <template v-if="column.dataIndex === 'action'">
  34. <a-space>
  35. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizProcessEdit')">编辑</a>
  36. <a-divider type="vertical" v-if="hasPerm(['bizProcessEdit', 'bizProcessDelete'], 'and')" />
  37. <a-button type="link" danger size="small" v-if="hasPerm('bizProcessDelete')" @click="deleteConfig(record)">删除</a-button>
  38. <a-divider type="vertical" v-if="hasPerm(['bizProcessEdit', 'bizProcessDelete'], 'or') && hasPerm('bizProcessNode')" />
  39. <a @click="nodeIndexRef.onOpen(record)" v-if="hasPerm('bizProcessNode')">节点</a>
  40. </a-space>
  41. </template>
  42. </template>
  43. </s-table>
  44. </a-card>
  45. <Form ref="formRef" @successful="tableRef.refresh()" />
  46. <NodeIndex ref="nodeIndexRef" @successful="tableRef.refresh()" />
  47. </template>
  48. <script setup name="bizprocess">
  49. import { cloneDeep } from 'lodash-es'
  50. import Form from './form.vue'
  51. import NodeIndex from './nodeIndex.vue'
  52. import bizProcessApi from '@/api/biz/bizProcessApi'
  53. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  54. import {Modal} from 'ant-design-vue';
  55. import {createVNode} from 'vue';
  56. const searchFormState = ref({})
  57. const searchFormRef = ref()
  58. const tableRef = ref()
  59. const formRef = ref()
  60. const nodeIndexRef = ref()
  61. const submitLoading = ref(false)
  62. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  63. const columns = [
  64. {
  65. title: '序号',
  66. width: 50,
  67. dataIndex: 'serial',
  68. align:'center'
  69. },
  70. {
  71. title: '工序名称',
  72. dataIndex: 'processName',
  73. align:'center'
  74. },
  75. {
  76. title: '创建时间',
  77. width: 180,
  78. dataIndex: 'createTime',
  79. align: 'center'
  80. },
  81. ]
  82. // 操作栏通过权限判断是否显示
  83. if (hasPerm(['bizProcessEdit', 'bizProcessDelete'])) {
  84. columns.push({
  85. title: '操作',
  86. dataIndex: 'action',
  87. align: 'center',
  88. width: 260
  89. })
  90. }
  91. const loadData = (parameter) => {
  92. const searchFormParam = cloneDeep(searchFormState.value)
  93. return bizProcessApi.bizProcessPage(Object.assign(parameter, searchFormParam)).then((data) => {
  94. return data
  95. })
  96. }
  97. // 重置
  98. const reset = () => {
  99. searchFormRef.value.resetFields()
  100. tableRef.value.refresh(true)
  101. }
  102. // 删除
  103. const deleteConfig = (record) => {
  104. Modal.confirm({
  105. title: '确定删除该数据吗?',
  106. icon: createVNode(ExclamationCircleOutlined),
  107. content: '',
  108. onOk() {
  109. submitLoading.value = true
  110. let params = [
  111. {
  112. id: record.id
  113. }
  114. ]
  115. bizProcessApi
  116. .bizProcessDelete(params)
  117. .then(() => {
  118. tableRef.value.refresh(true)
  119. })
  120. .finally(() => {
  121. submitLoading.value = false
  122. })
  123. },
  124. onCancel() {}
  125. })
  126. }
  127. </script>