index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: select,
  15. }"
  16. @get-list="getList"
  17. >
  18. <template #slotName="{ item }">
  19. {{ item.createTime }}
  20. </template>
  21. </byTable>
  22. </div>
  23. <el-dialog
  24. :title="modalType == 'add' ? '新增' : '编辑'"
  25. v-model="dialogVisible"
  26. width="400"
  27. v-loading="loading"
  28. >
  29. <byForm
  30. :formConfig="formConfig"
  31. :formOption="formOption"
  32. v-model="formData.data"
  33. :rules="rules"
  34. ref="byform"
  35. >
  36. </byForm>
  37. <template #footer>
  38. <el-button @click="dialogVisible = false" size="large"
  39. >取 消</el-button
  40. >
  41. <el-button
  42. type="primary"
  43. @click="submitForm('byform')"
  44. size="large"
  45. :loading="submitLoading"
  46. >
  47. 确 定
  48. </el-button>
  49. </template>
  50. </el-dialog>
  51. </div>
  52. </template>
  53. <script setup>
  54. /* eslint-disable vue/no-unused-components */
  55. import { ElMessage, ElMessageBox } from 'element-plus'
  56. import byTable from '@/components/byTable/index'
  57. import byForm from '@/components/byForm/index'
  58. import { computed, defineComponent, ref } from 'vue'
  59. const loading = ref(false)
  60. const submitLoading = ref(false)
  61. const dictCommonModal = ref(false)
  62. const sourceList = ref({
  63. data: [],
  64. pagination: {
  65. total: 3,
  66. pageNum: 1,
  67. pageSize: 10,
  68. status:1,
  69. },
  70. })
  71. let dialogVisible = ref(false)
  72. let roomDialogVisible = ref(false)
  73. let modalType = ref('add')
  74. let rules = ref({
  75. classifyName: [
  76. { required: true, message: '请输入功能模块', trigger: 'blur' },
  77. ],
  78. flowKey: [{ required: true, message: '请输入流程标识', trigger: 'blur' }],
  79. flowName: [{ required: true, message: '请输入流程名称', trigger: 'blur' }],
  80. })
  81. const { proxy } = getCurrentInstance()
  82. const selectConfig = computed(() => {
  83. return [
  84. {
  85. label: '流程类型',
  86. prop: 'flowInfoId',
  87. data: [],
  88. },
  89. {
  90. label: '流程状态',
  91. prop: 'status',
  92. data: [
  93. {
  94. label: '待处理',
  95. value: '1',
  96. },
  97. {
  98. label: '已发起',
  99. value: '2',
  100. },
  101. {
  102. label: '已处理',
  103. value: '3',
  104. },
  105. ],
  106. },
  107. ]
  108. })
  109. const config = computed(() => {
  110. return [
  111. {
  112. attrs: {
  113. label: '流程类型',
  114. prop: 'flowName',
  115. },
  116. },
  117. {
  118. attrs: {
  119. label: '流程标题',
  120. prop: 'title',
  121. },
  122. },
  123. {
  124. attrs: {
  125. label: '处理类型',
  126. width: 100,
  127. prop: 'status',
  128. },
  129. render(status) {
  130. return status == 0 || status == 1 ? '待处理' : status == 2 ? '已通过' : '已驳回'
  131. },
  132. },
  133. {
  134. attrs: {
  135. label: '发起人',
  136. prop: 'createUserName',
  137. },
  138. },
  139. {
  140. attrs: {
  141. label: '发起时间',
  142. prop: 'createTime',
  143. },
  144. },
  145. {
  146. attrs: {
  147. label: '操作',
  148. width: '200',
  149. align: 'right',
  150. },
  151. // 渲染 el-button,一般用在最后一列。
  152. renderHTML(row) {
  153. return [
  154. {
  155. attrs: {
  156. label: row.status == 0 || row.status == 1 ? '办理' : '查看',
  157. type: 'primary',
  158. text: true,
  159. bg: true,
  160. disabled: false,
  161. },
  162. el: 'button',
  163. click() {
  164. if(row.status != 1 && row.status != 0) {
  165. proxy.$router.push({
  166. path: "/platform_manage/process/processApproval",
  167. query: {
  168. flowKey: row.flowKey,
  169. id: row.id,
  170. processType:20,
  171. version:row.version
  172. },
  173. });
  174. return
  175. }
  176. proxy.post('flowExample/getApprovalRecord',{id:row.id}).then(res=>{
  177. if(res.recordList.length > 0) {
  178. let data = res.recordList.filter(item => item.status === 2)
  179. let nodeType= 0
  180. if (data && data.length > 0) {
  181. nodeType = data[0].nodeType
  182. }
  183. proxy.$router.push({
  184. path: "/platform_manage/process/processApproval",
  185. query: {
  186. flowKey: row.flowKey,
  187. id: row.id,
  188. processType:nodeType == 1 ? 30 : 10,
  189. version:row.version
  190. },
  191. });
  192. }
  193. })
  194. },
  195. }
  196. ]
  197. },
  198. },
  199. ]
  200. })
  201. let dtlData = reactive({
  202. data: {},
  203. })
  204. let formData = reactive({
  205. data: {},
  206. treeData: [],
  207. })
  208. const formOption = reactive({
  209. inline: true,
  210. labelWidth: 100,
  211. itemWidth: 100,
  212. rules: [],
  213. })
  214. const byform = ref(null)
  215. const treeData = ref([])
  216. const formConfig = computed(() => {
  217. return [
  218. {
  219. type: 'input',
  220. prop: 'classifyName',
  221. label: '功能模块',
  222. },
  223. {
  224. type: 'input',
  225. prop: 'flowKey',
  226. label: '流程标识',
  227. isHide: modalType.value == 'edit',
  228. },
  229. {
  230. type: 'input',
  231. prop: 'flowName',
  232. label: '流程名称',
  233. },
  234. ]
  235. })
  236. const flowJump = (row,type) => {
  237. proxy.post('/flowProcess/jump', {flowId:row.id,handleType:type,version:row.version,data:{}}).then((message) => {
  238. console.log(message)
  239. if(message){
  240. ElMessage.success('操作成功')
  241. getList()
  242. }
  243. })
  244. }
  245. const getFlowType = () => {
  246. proxy
  247. .post('/flowExample/getFlowType')
  248. .then((message) => {
  249. console.log(message)
  250. selectConfig.value[0].data = message.map((item) => {
  251. return {
  252. label: item.flowName,
  253. value: item.id,
  254. }
  255. })
  256. })
  257. }
  258. getFlowType()
  259. const getUrlObj = {
  260. 1:'/flowExample/getToBeProcessedPage',
  261. 2:'/flowExample/getHaveInitiatedPage',
  262. 3:'/flowExample/getProcessedPage',
  263. }
  264. const getList = async (req) => {
  265. sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
  266. loading.value = true
  267. proxy
  268. .post( getUrlObj[sourceList.value.pagination.status], sourceList.value.pagination)
  269. .then((message) => {
  270. console.log(message)
  271. sourceList.value.data = message.rows
  272. sourceList.value.pagination.total = message.total
  273. setTimeout(() => {
  274. loading.value = false
  275. }, 200)
  276. })
  277. }
  278. const openModal = () => {
  279. dialogVisible.value = true
  280. modalType.value = 'add'
  281. formData.data = {}
  282. }
  283. const selection = ref({
  284. data: [],
  285. })
  286. const select = (_selection, row) => {
  287. selection.value.data = _selection
  288. console.log(_selection.length)
  289. }
  290. const tree = ref(null)
  291. const submitTree = () => {
  292. proxy
  293. .post('/tenantInfo/bindingMenu', {
  294. tenantId: selection.value.data[0].tenantId,
  295. menuIdList: tree.value.getCheckedKeys(),
  296. })
  297. .then((res) => {
  298. ElMessage({
  299. message: '保存成功',
  300. type: 'success',
  301. })
  302. roomDialogVisible.value = false
  303. })
  304. }
  305. const submitForm = () => {
  306. byform.value.handleSubmit((valid) => {
  307. submitLoading.value = true
  308. proxy
  309. .post('/flowInfo/' + modalType.value, formData.data)
  310. .then((res) => {
  311. ElMessage({
  312. message: modalType.value == 'add' ? '添加成功' : '编辑成功',
  313. type: 'success',
  314. })
  315. dialogVisible.value = false
  316. submitLoading.value = false
  317. getList()
  318. })
  319. })
  320. }
  321. const getDtl = (row) => {
  322. formData.data = { ...row }
  323. modalType.value = 'edit'
  324. dialogVisible.value = true
  325. }
  326. const changeStatus = (row) => {
  327. modalType.value = 'edit'
  328. proxy
  329. .post('/flowInfo/edit', { ...row, status: row.status === 0 ? 1 : 0 })
  330. .then((res) => {
  331. ElMessage({
  332. message: '操作成功',
  333. type: 'success',
  334. })
  335. getList()
  336. })
  337. }
  338. getList()
  339. </script>
  340. <style lang="scss" scoped>
  341. .tenant {
  342. padding: 20px;
  343. }
  344. </style>