index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <script setup lang="ts">
  2. import AForm from '@/components/AForm/index.vue'
  3. import { FormConfigType } from '@/components/AForm/type'
  4. import { ToolbarConfigType } from '@/components/AToolbar/type'
  5. import { ColumnConfigType } from '@/components/ATable/type'
  6. import { StrAnyObj, StrAnyObjArr } from '@/typings'
  7. import { getPageApi, getDetailApi, editApi } from '@/api/business/log/userOperation'
  8. const queryRef = ref<InstanceType<typeof AForm>>()
  9. const formRef = ref<InstanceType<typeof AForm>>()
  10. const showQuery = ref<boolean>(true)
  11. const pageTotal = ref<number>(0)
  12. const queryData = ref<StrAnyObj>({ pageNum: 1, pageSize: 10 })
  13. const tableData = ref<StrAnyObjArr>([])
  14. const formData = ref<StrAnyObj>({})
  15. const dialogVisible = ref<boolean>(false)
  16. const queryConfig: FormConfigType[] = [
  17. {
  18. type: 'input',
  19. prop: 'moduleName',
  20. label: '操作模块'
  21. },
  22. {
  23. type: 'input',
  24. prop: 'operatorName',
  25. label: '操作人'
  26. },
  27. {
  28. type: 'select',
  29. prop: 'operationType',
  30. label: '操作类型',
  31. option: [
  32. {
  33. key: 2,
  34. label: '新增'
  35. },
  36. {
  37. key: 3,
  38. label: '修改'
  39. },
  40. {
  41. key: 4,
  42. label: '删除'
  43. }
  44. ]
  45. },
  46. {
  47. type: 'select',
  48. prop: 'auditStatus',
  49. label: '审核状态',
  50. option: [
  51. {
  52. key: 0,
  53. label: '待审核'
  54. },
  55. {
  56. key: 1,
  57. label: '通过'
  58. },
  59. {
  60. key: 2,
  61. label: '拒绝'
  62. }
  63. ]
  64. }
  65. ]
  66. const toolbarConfig: ToolbarConfigType[] = [
  67. {
  68. common: 'search',
  69. click() {
  70. queryData.value.pageNum = 1
  71. getPage()
  72. }
  73. },
  74. {
  75. common: 'reset',
  76. click() {
  77. queryRef.value?.resetFields()
  78. getPage()
  79. }
  80. }
  81. ]
  82. const columnConfig: ColumnConfigType[] = [
  83. {
  84. prop: 'moduleName',
  85. label: '模块标题',
  86. width: 160
  87. },
  88. {
  89. prop: 'operatorName',
  90. label: '操作人姓名',
  91. width: 160
  92. },
  93. {
  94. prop: 'operationType',
  95. label: '操作类型',
  96. formatter: (row) => {
  97. switch (row.operationType) {
  98. case 2:
  99. return '新增'
  100. case 3:
  101. return '修改'
  102. case 4:
  103. return '删除'
  104. }
  105. return ''
  106. },
  107. width: 120
  108. },
  109. {
  110. prop: 'createTime',
  111. label: '操作时间',
  112. width: 160
  113. },
  114. {
  115. prop: 'description',
  116. label: '操作描述'
  117. },
  118. {
  119. prop: 'auditStatus',
  120. label: '审核状态',
  121. formatter: (row) => {
  122. switch (row.auditStatus) {
  123. case 0:
  124. return '待审核'
  125. case 1:
  126. return '通过'
  127. case 2:
  128. return '拒绝'
  129. }
  130. return ''
  131. },
  132. width: 120
  133. },
  134. {
  135. prop: 'auditTime',
  136. label: '审核时间',
  137. width: 160
  138. },
  139. {
  140. prop: 'remark',
  141. label: '审核注释'
  142. },
  143. {
  144. width: 120,
  145. handleConfig: [
  146. {
  147. if: (row) => row.auditStatus == 0,
  148. text: '审核',
  149. click(row) {
  150. dialogVisible.value = true
  151. getDetailApi({ id: row.id }).then((resp: StrAnyObj) => {
  152. formData.value = resp
  153. console.log(resp)
  154. console.log(JSON.parse(resp.operationData))
  155. console.log(JSON.parse(resp.sourceData))
  156. })
  157. }
  158. }
  159. ]
  160. }
  161. ]
  162. onMounted(() => {
  163. getPage()
  164. })
  165. function getPage() {
  166. getPageApi(queryData.value).then((resp) => {
  167. tableData.value = resp.records
  168. pageTotal.value = resp.total
  169. })
  170. }
  171. function formSubmit(status: boolean) {
  172. formRef.value?.validate(() => {
  173. editApi({ ...formData.value, auditStatus: status ? 1 : 2 }).then(() => {
  174. dialogVisible.value = false
  175. ElMessage.success('操作成功')
  176. getPage()
  177. })
  178. })
  179. }
  180. </script>
  181. <template>
  182. <div>
  183. <el-card v-if="showQuery">
  184. <a-form ref="queryRef" v-model="queryData" :config="queryConfig" :span="6"> </a-form>
  185. </el-card>
  186. <a-table
  187. :data="tableData"
  188. :page-total="pageTotal"
  189. :toolbar-config="toolbarConfig"
  190. :column-config="columnConfig"
  191. v-model:show-query="showQuery"
  192. v-model:page-num="queryData.pageNum"
  193. v-model:page-size="queryData.pageSize"
  194. @page-num-change="getPage"
  195. @page-size-change="getPage"
  196. >
  197. </a-table>
  198. <a-dialog v-model="dialogVisible" title="审核" :footer="false">
  199. <el-input style="padding: 20px 0" type="textarea" v-model="formData.remark" placeholder="请输入审核备注" />
  200. <div style="text-align: center">
  201. <div>
  202. <el-button plain type="info" @click="dialogVisible = false">关 闭</el-button>
  203. <el-button plain type="success" @click="formSubmit(true)">通 过</el-button>
  204. <el-button plain type="warning" @click="formSubmit(false)">拒 绝</el-button>
  205. </div>
  206. </div>
  207. </a-dialog>
  208. </div>
  209. </template>