index.vue 5.4 KB

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