index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="splitpanes-container">
  3. <el-card shadow="hover" header="表单中心">
  4. <el-alert
  5. title="用于发起自定义表单审批流程,点击选择左侧表单类型进行表单数据管理"
  6. type="success"
  7. :closable="false"
  8. class="mb15"
  9. ></el-alert>
  10. <splitpanes class="default-theme">
  11. <pane :size="20">
  12. <el-card shadow="hover" header="流程表单">
  13. <el-table v-loading="loading" :data="tableData.data" @current-change="handleCurrentForm" highlight-current-row>
  14. <el-table-column prop="id" label="ID" width="100" />
  15. <el-table-column prop="name" label="表单名称" />
  16. </el-table>
  17. <pagination
  18. v-show="tableData.total>0"
  19. :total="tableData.total"
  20. v-model:page="tableData.param.pageNum"
  21. v-model:limit="tableData.param.pageSize"
  22. @pagination="flowFormList"
  23. layout="prev, next"
  24. />
  25. </el-card>
  26. </pane>
  27. <pane :size="80">
  28. <el-card shadow="hover" :header="'表单数据'+(currentForm.name?('-'+currentForm.name):'')">
  29. <el-row :gutter="10" class="mb8" v-show="showTablePanel">
  30. <el-col :span="1.5">
  31. <el-button
  32. type="primary"
  33. @click="handleDataAdd"
  34. v-auth="'api/v1/flow/flowForm/addFormData'"
  35. ><el-icon><ele-Plus /></el-icon>发起表单审批</el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button
  39. type="success"
  40. :disabled="single"
  41. @click="handleDataUpdate(null)"
  42. v-auth="'api/v1/flow/flowForm/editFormData'"
  43. ><el-icon><ele-Edit /></el-icon>修改</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="danger"
  48. :disabled="multiple"
  49. @click="handleDataDelete(null)"
  50. v-auth="'api/v1/flow/flowForm/delFormData'"
  51. ><el-icon><ele-Delete /></el-icon>删除</el-button>
  52. </el-col>
  53. <el-col :span="1.5">
  54. <el-button @click="getFormDataList"><el-icon><ele-Refresh /></el-icon>刷新</el-button>
  55. </el-col>
  56. </el-row>
  57. <el-table v-loading="formLoading" :data="tableFormData" @selection-change="handleSelectionChange">
  58. <el-table-column type="selection" width="55" align="center" />
  59. <el-table-column label="主键" align="center" prop="id"
  60. min-width="150px"
  61. />
  62. <el-table-column v-for="(item,index) in fromFields" :key="item.field" :label="item.title" align="center" :prop="item.field"
  63. min-width="150px"
  64. />
  65. <el-table-column label="状态" align="center" prop="status" min-width="150px">
  66. <template #default="scope">
  67. <el-tag :type="columnColor(scope.row)">{{ statusFormat(scope.row) }}</el-tag>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="创建时间" align="center" prop="createdAt"
  71. min-width="150px"
  72. >
  73. <template #default="scope">
  74. <span>{{ proxy.parseTime(scope.row.created_at, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="创建人" align="center" prop="created_user.userNickname"
  78. min-width="150px"
  79. />
  80. <el-table-column label="操作" align="center" class-name="small-padding" min-width="200px" fixed="right">
  81. <template #default="scope">
  82. <el-button
  83. type="primary"
  84. link
  85. @click="handleDataView(scope.row)"
  86. v-auth="'api/v1/flow/flowForm/getFormData'"
  87. ><el-icon><ele-View /></el-icon>详情</el-button>
  88. <el-button
  89. type="primary"
  90. link
  91. @click="handleDataUpdate(scope.row)"
  92. v-auth="'api/v1/flow/flowForm/editFormData'"
  93. ><el-icon><ele-EditPen /></el-icon>修改</el-button>
  94. <el-button
  95. v-if="scope.row.actionBtn && scope.row.actionBtn.type!='disabled'"
  96. type="primary"
  97. link
  98. @click="handleStartFlow(scope.row)"
  99. ><el-icon><ele-Coordinate/></el-icon>{{scope.row.actionBtn.title}}</el-button>
  100. <el-button
  101. type="primary"
  102. link
  103. @click="handleDataDelete(scope.row)"
  104. v-auth="'api/v1/flow/flowForm/delFormData'"
  105. ><el-icon><ele-DeleteFilled /></el-icon>删除</el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <pagination
  110. v-show="tableFormParam.total>0"
  111. :total="tableFormParam.total"
  112. v-model:page="tableFormParam.pageNum"
  113. v-model:limit="tableFormParam.pageSize"
  114. @pagination="getFormDataList"
  115. />
  116. </el-card>
  117. </pane>
  118. </splitpanes>
  119. </el-card>
  120. <add-form-data
  121. ref="addFormDataRef"
  122. @getFormDataList="getFormDataList"
  123. >
  124. </add-form-data>
  125. <data-detail
  126. ref="dataDetailRef"
  127. >
  128. </data-detail>
  129. <checkFlow ref="ckFlowRef" @getList="getFormDataList"></checkFlow>
  130. </div>
  131. </template>
  132. <script lang="ts" setup>
  133. import checkFlow from "/@/components/gFlow/checkFlow.vue"
  134. import { Splitpanes, Pane } from 'splitpanes';
  135. import 'splitpanes/dist/splitpanes.css';
  136. import {getCurrentInstance, onMounted, reactive, ref, toRefs, unref} from "vue";
  137. import {delFlowFormData, listFlowForm, ListFlowFormData} from "/@/api/flow/flowForm";
  138. import {
  139. FlowFormTableColumns,
  140. FlowFormTableDataState,
  141. FormFieldsData
  142. } from "/@/views/flow/flowForm/list/component/model";
  143. import AddFormData from "/@/views/flow/flowForm/list/component/addFormData.vue";
  144. import {FlowDemoTableColumns} from "/@/views/flow/flowDemo/list/component/model";
  145. import {ElMessage, ElMessageBox} from "element-plus";
  146. import DataDetail from "/@/views/flow/flowForm/list/component/dataDetail.vue";
  147. const {proxy} = <any>getCurrentInstance()
  148. const loading = ref(false)
  149. const single = ref(true)
  150. const multiple = ref(true)
  151. const ckFlowRef = ref()
  152. const showTablePanel = ref(false)
  153. const currentForm = ref<FlowFormTableColumns>({} as FlowFormTableColumns)
  154. const addFormDataRef = ref()
  155. const dataDetailRef = ref()
  156. const formLoading = ref(false)
  157. const fromFields = ref<FormFieldsData[]>([])
  158. const tableFormData = ref<any[]>([])
  159. const tableFormParam = ref({
  160. total:0,
  161. pageNum: 1,
  162. pageSize: 10,
  163. formId: 0
  164. })
  165. const state = reactive<FlowFormTableDataState>({
  166. ids:[],
  167. tableData: {
  168. data: [],
  169. total: 0,
  170. loading: false,
  171. param: {
  172. pageNum: 1,
  173. pageSize: 10,
  174. name: undefined,
  175. status: 1,
  176. isPub:true,
  177. createdAt: undefined,
  178. dateRange: []
  179. },
  180. },
  181. });
  182. const {tableData} = toRefs(state)
  183. onMounted(()=>{
  184. initTableData();
  185. })
  186. const initTableData = ()=>{
  187. flowFormList();
  188. }
  189. const flowFormList = ()=>{
  190. loading.value = true
  191. listFlowForm(state.tableData.param).then((res:any)=>{
  192. let list = res.data.list??[];
  193. list.map((item:any)=>{
  194. item.createdBy = item.createdUser?.userNickname
  195. })
  196. state.tableData.data = list;
  197. state.tableData.total = res.data.total;
  198. loading.value = false
  199. })
  200. }
  201. const handleCurrentForm = (row:FlowFormTableColumns)=>{
  202. showTablePanel.value = true
  203. currentForm.value = row
  204. tableFormParam.value = {
  205. total:0,
  206. pageNum: 1,
  207. pageSize: 10,
  208. formId: row.id
  209. }
  210. getFormDataList()
  211. }
  212. const getFormDataList = ()=>{
  213. formLoading.value = true
  214. ListFlowFormData(tableFormParam.value).then((res:any)=>{
  215. tableFormData.value = res.data.list
  216. tableFormParam.value.total = res.data.total
  217. fromFields.value = res.data.fields.filter((item:FormFieldsData)=>{
  218. return item.type=='input' && item.display && !item.hidden
  219. }).slice(0,3)
  220. formLoading.value = false
  221. })
  222. }
  223. // 多选框选中数据
  224. const handleSelectionChange = (selection:Array<any>) => {
  225. state.ids = selection.map(item => item.id)
  226. single.value = selection.length!=1
  227. multiple.value = !selection.length
  228. }
  229. const columnColor=(row:FlowDemoTableColumns)=>{
  230. switch (row.status.toString()){
  231. case '-1':
  232. return "danger"
  233. case '0':
  234. return "info"
  235. case '1':
  236. return "warning"
  237. case '2':
  238. return "success"
  239. }
  240. }
  241. // 字典选项数据
  242. const {
  243. flow_status,
  244. } = proxy.useDict(
  245. 'flow_status',
  246. )
  247. // 审核状态字典翻译
  248. const statusFormat = (row:FlowDemoTableColumns) => {
  249. return proxy.selectDictLabel(flow_status.value, row.status);
  250. }
  251. const handleDataAdd = ()=>{
  252. currentForm.value.dataId = 0
  253. addFormDataRef.value.openDialog(currentForm.value)
  254. }
  255. const handleDataView = (row:any)=>{
  256. currentForm.value.dataId = row.id as number
  257. currentForm.value.actionBtn = row.actionBtn
  258. dataDetailRef.value.openDialog(currentForm.value)
  259. }
  260. const handleDataUpdate = (row:any)=>{
  261. if(row==null|| typeof row == 'undefined'){
  262. currentForm.value.dataId = state.ids[0]
  263. }else{
  264. currentForm.value.dataId = row.id as number
  265. }
  266. addFormDataRef.value.openDialog(currentForm.value)
  267. }
  268. const handleStartFlow =(row: FlowDemoTableColumns|null)=>{
  269. ckFlowRef.value.handleStartFlow(row)
  270. }
  271. const handleDataDelete = (row:any)=>{
  272. let msg = '你确定要删除所选数据?';
  273. let id:number[] = [] ;
  274. if(row){
  275. msg = `此操作将永久删除数据,是否继续?`
  276. id = [row.id]
  277. }else{
  278. id = state.ids
  279. }
  280. if(id.length===0){
  281. ElMessage.error('请选择要删除的数据。');
  282. return
  283. }
  284. ElMessageBox.confirm(msg, '提示', {
  285. confirmButtonText: '确认',
  286. cancelButtonText: '取消',
  287. type: 'warning',
  288. }).then(() => {
  289. delFlowFormData({formId:currentForm.value.id,ids:id}).then(()=>{
  290. ElMessage.success('删除成功');
  291. getFormDataList();
  292. })
  293. }).catch()
  294. }
  295. </script>
  296. <style scoped lang="scss">
  297. </style>