index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div class="app-container">
  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. },
  69. })
  70. let dialogVisible = ref(false)
  71. let roomDialogVisible = ref(false)
  72. let modalType = ref('add')
  73. let rules = ref({
  74. classifyName: [
  75. { required: true, message: '请输入功能模块', trigger: 'blur' },
  76. ],
  77. flowKey: [{ required: true, message: '请输入流程标识', trigger: 'blur' }],
  78. flowName: [{ required: true, message: '请输入流程名称', trigger: 'blur' }],
  79. })
  80. const { proxy } = getCurrentInstance()
  81. const selectConfig = computed(() => {
  82. return [
  83. {
  84. label: '流程类型',
  85. prop: 'flowInfoId',
  86. data: [],
  87. },
  88. {
  89. label: '流程状态',
  90. prop: 'status',
  91. data: [
  92. {
  93. label: '进行中',
  94. value: '1',
  95. },
  96. {
  97. label: '已结束',
  98. value: '2',
  99. },
  100. ],
  101. },
  102. ]
  103. })
  104. const config = computed(() => {
  105. return [
  106. {
  107. attrs: {
  108. label: '流程类型',
  109. prop: 'title',
  110. },
  111. },
  112. {
  113. attrs: {
  114. label: '流程标题',
  115. prop: 'title',
  116. },
  117. },
  118. {
  119. attrs: {
  120. label: '流程状态',
  121. width: 100,
  122. prop: 'status',
  123. },
  124. render(status) {
  125. //1审核中 2审核通过 3审核不通过
  126. return status == 0 || status == 1 ? '待处理' : '已结束'
  127. },
  128. },
  129. {
  130. attrs: {
  131. label: '发起人',
  132. prop: 'createUserName',
  133. },
  134. },
  135. {
  136. attrs: {
  137. label: '发起时间',
  138. prop: 'createTime',
  139. },
  140. },
  141. {
  142. attrs: {
  143. label: '操作',
  144. width: '200',
  145. align: 'right',
  146. },
  147. // 渲染 el-button,一般用在最后一列。
  148. renderHTML(row) {
  149. return [
  150. row.status != 1
  151. ? {
  152. attrs: {
  153. label: '重新审批',
  154. type: 'primary',
  155. text: true,
  156. bg: true,
  157. disabled: false,
  158. },
  159. el: 'button',
  160. click() {
  161. },
  162. }: {},
  163. row.status == 1?
  164. {
  165. attrs: {
  166. label: '退回上一步',
  167. text: true,
  168. bg: true,
  169. type: 'primary',
  170. disabled: false,
  171. style: {
  172. color: '#e6a23c',
  173. },
  174. },
  175. el: 'button',
  176. click() {
  177. flowJump(row,3)
  178. },
  179. }:{},
  180. row.status == 1?
  181. {
  182. attrs: {
  183. label: '向下流转',
  184. text: true,
  185. bg: true,
  186. type: 'primary',
  187. disabled: false,
  188. style: {
  189. color: '#e6a23c',
  190. },
  191. },
  192. el: 'button',
  193. click() {
  194. flowJump(row,1)
  195. },
  196. }:{},
  197. ]
  198. },
  199. },
  200. ]
  201. })
  202. let dtlData = reactive({
  203. data: {},
  204. })
  205. let formData = reactive({
  206. data: {},
  207. treeData: [],
  208. })
  209. const formOption = reactive({
  210. inline: true,
  211. labelWidth: 100,
  212. itemWidth: 100,
  213. rules: [],
  214. })
  215. const byform = ref(null)
  216. const treeData = ref([])
  217. const formConfig = computed(() => {
  218. return [
  219. {
  220. type: 'input',
  221. prop: 'classifyName',
  222. label: '功能模块',
  223. },
  224. {
  225. type: 'input',
  226. prop: 'flowKey',
  227. label: '流程标识',
  228. isHide: modalType.value == 'edit',
  229. },
  230. {
  231. type: 'input',
  232. prop: 'flowName',
  233. label: '流程名称',
  234. },
  235. ]
  236. })
  237. const flowJump = (row,type) => {
  238. proxy.post('/flowProcess/jump', {flowId:row.id,handleType:type,version:row.version,data:{}}).then((message) => {
  239. console.log(message)
  240. if(message){
  241. ElMessage.success('操作成功')
  242. getList()
  243. }
  244. })
  245. }
  246. const getFlowType = () => {
  247. proxy
  248. .post('/flowExample/getFlowType')
  249. .then((message) => {
  250. console.log(message)
  251. selectConfig.value[0].data = message.map((item) => {
  252. return {
  253. label: item.flowName,
  254. value: item.id,
  255. }
  256. })
  257. })
  258. }
  259. getFlowType()
  260. const getList = async (req) => {
  261. sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
  262. loading.value = true
  263. proxy
  264. .post('/flowExample/page', sourceList.value.pagination)
  265. .then((message) => {
  266. console.log(message)
  267. sourceList.value.data = message.rows
  268. sourceList.value.pagination.total = message.total
  269. setTimeout(() => {
  270. loading.value = false
  271. }, 200)
  272. })
  273. }
  274. const openModal = () => {
  275. dialogVisible.value = true
  276. modalType.value = 'add'
  277. formData.data = {}
  278. }
  279. const selection = ref({
  280. data: [],
  281. })
  282. const select = (_selection, row) => {
  283. selection.value.data = _selection
  284. console.log(_selection.length)
  285. }
  286. const tree = ref(null)
  287. const submitTree = () => {
  288. proxy
  289. .post('/tenantInfo/bindingMenu', {
  290. tenantId: selection.value.data[0].tenantId,
  291. menuIdList: tree.value.getCheckedKeys(),
  292. })
  293. .then((res) => {
  294. ElMessage({
  295. message: '保存成功',
  296. type: 'success',
  297. })
  298. roomDialogVisible.value = false
  299. })
  300. }
  301. const submitForm = () => {
  302. byform.value.handleSubmit((valid) => {
  303. submitLoading.value = true
  304. proxy
  305. .post('/flowInfo/' + modalType.value, formData.data)
  306. .then((res) => {
  307. ElMessage({
  308. message: modalType.value == 'add' ? '添加成功' : '编辑成功',
  309. type: 'success',
  310. })
  311. dialogVisible.value = false
  312. submitLoading.value = false
  313. getList()
  314. })
  315. })
  316. }
  317. const getDtl = (row) => {
  318. formData.data = { ...row }
  319. modalType.value = 'edit'
  320. dialogVisible.value = true
  321. }
  322. const changeStatus = (row) => {
  323. modalType.value = 'edit'
  324. proxy
  325. .post('/flowInfo/edit', { ...row, status: row.status === 0 ? 1 : 0 })
  326. .then((res) => {
  327. ElMessage({
  328. message: '操作成功',
  329. type: 'success',
  330. })
  331. getList()
  332. })
  333. }
  334. getList()
  335. </script>
  336. <style lang="scss" scoped>
  337. .tenant {
  338. padding: 20px;
  339. }
  340. </style>