index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <div class="user">
  3. <div class="tree">
  4. <treeList
  5. :data="treeListData"
  6. v-model="sourceList.pagination.tenantId"
  7. node-key="id"
  8. @change="treeChange"
  9. >
  10. </treeList>
  11. </div>
  12. <div class="content">
  13. <byTable
  14. :source="sourceList.data"
  15. :pagination="sourceList.pagination"
  16. :config="config"
  17. :loading="loading"
  18. highlight-current-row
  19. :selectConfig="selectConfig"
  20. :table-events="{
  21. //element talbe事件都能传
  22. select: select,
  23. }"
  24. :action-list="[
  25. {
  26. text: '添加流程',
  27. action: () => openModal('add'),
  28. disabled: !sourceList.pagination.tenantId,
  29. },
  30. ]"
  31. @get-list="getList"
  32. >
  33. <template #slotName="{ item }">
  34. {{ item.createTime }}
  35. </template>
  36. </byTable>
  37. </div>
  38. <el-dialog
  39. :title="modalType == 'add' ? '新增' : '编辑'"
  40. v-model="dialogVisible"
  41. width="500"
  42. v-loading="loading"
  43. >
  44. <byForm
  45. :formConfig="formConfig"
  46. :formOption="formOption"
  47. v-model="formData.data"
  48. :rules="rules"
  49. ref="byform"
  50. >
  51. </byForm>
  52. <template #footer>
  53. <el-button @click="dialogVisible = false" size="large"
  54. >取 消</el-button
  55. >
  56. <el-button
  57. type="primary"
  58. v-no-double-click="submitForm"
  59. size="large"
  60. :loading="submitLoading"
  61. >
  62. 确 定
  63. </el-button>
  64. </template>
  65. </el-dialog>
  66. <!-- 版本切换模态框 -->
  67. <el-dialog
  68. title="版本切换"
  69. v-model="versionVisible"
  70. width="500"
  71. v-loading="loading"
  72. >
  73. <el-form>
  74. <el-form-item label="流程名称">
  75. <el-input
  76. v-model="formData.flowName"
  77. disabled
  78. placeholder="请输入流程名称"
  79. ></el-input>
  80. </el-form-item>
  81. <el-form-item label="当前版本">
  82. <el-select v-model="formData.version" placeholder="请选择">
  83. <el-option
  84. v-for="item in versionList"
  85. :key="item.id"
  86. :label="'v' + item.versionNumber"
  87. :value="item.id"
  88. ></el-option>
  89. </el-select>
  90. </el-form-item>
  91. </el-form>
  92. <template #footer>
  93. <el-button @click="versionVisible = false" size="large"
  94. >取 消</el-button
  95. >
  96. <el-button
  97. type="primary"
  98. @click="changeVersion(formData.version)"
  99. size="large"
  100. :loading="submitLoading"
  101. >
  102. 确 定
  103. </el-button>
  104. </template>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script setup name="ProcessConfig">
  109. /* eslint-disable vue/no-unused-components */
  110. import { ElMessage, ElMessageBox } from 'element-plus'
  111. import byTable from '@/components/byTable/index'
  112. import byForm from '@/components/byForm/index'
  113. import treeList from '@/components/treeList/index'
  114. import { computed, defineComponent, ref } from 'vue'
  115. const loading = ref(false)
  116. const submitLoading = ref(false)
  117. const sourceList = ref({
  118. data: [],
  119. pagination: {
  120. total: 3,
  121. pageNum: 1,
  122. pageSize: 10,
  123. },
  124. })
  125. let dialogVisible = ref(false)
  126. const versionVisible = ref(false)
  127. let modalType = ref('add')
  128. let rules = ref({
  129. roleKey: [{ required: true, message: '请选择部门', trigger: 'blur' }],
  130. nickName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
  131. userName: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
  132. })
  133. const { proxy } = getCurrentInstance()
  134. const selectConfig = computed(() => {
  135. return []
  136. })
  137. const config = computed(() => {
  138. return [
  139. {
  140. attrs: {
  141. label: '功能模块',
  142. prop: 'classifyName',
  143. },
  144. },
  145. {
  146. attrs: {
  147. label: '流程标识',
  148. prop: 'flowKey',
  149. },
  150. },
  151. {
  152. attrs: {
  153. label: '流程名称',
  154. prop: 'flowName',
  155. },
  156. },
  157. {
  158. attrs: {
  159. label: '当前版本',
  160. },
  161. // 渲染 el-button,一般用在最后一列。
  162. renderHTML(row) {
  163. return [
  164. {
  165. attrs: {
  166. label: 'v' + row.versionNumber,
  167. type: 'primary',
  168. text: true,
  169. },
  170. el: 'button',
  171. click() {
  172. getVersionList(row)
  173. },
  174. },
  175. ]
  176. },
  177. },
  178. {
  179. attrs: {
  180. label: '操作',
  181. width: '200',
  182. align: 'right',
  183. },
  184. // 渲染 el-button,一般用在最后一列。
  185. renderHTML(row) {
  186. return [
  187. {
  188. attrs: {
  189. label: '新建版本',
  190. type: 'primary',
  191. text: true,
  192. },
  193. el: 'button',
  194. click() {
  195. getDtl(row)
  196. },
  197. },
  198. ]
  199. },
  200. },
  201. ]
  202. })
  203. let versionList = ref([])
  204. const getVersionList = (row) => {
  205. formData.flowName = row.flowName
  206. formData.version = row.id
  207. versionVisible.value = true
  208. proxy.post('/flowDefinition/getVersionList',{
  209. flowKey:row.flowKey,
  210. tenantId:row.tenantId
  211. }).then((message) => {
  212. versionList.value = message
  213. console.log(versionList)
  214. })
  215. }
  216. const changeVersion = (id) => {
  217. if(!id){
  218. ElMessage.error('请选择版本')
  219. return
  220. }
  221. proxy.post('/flowDefinition/updateVersion',{
  222. id:id
  223. }).then((message) => {
  224. ElMessage.success('切换成功')
  225. versionVisible.value = false
  226. getList()
  227. })
  228. }
  229. let formData = reactive({
  230. data: {},
  231. })
  232. const formOption = reactive({
  233. inline: true,
  234. labelWidth: 100,
  235. itemWidth: 100,
  236. rules: [],
  237. })
  238. const byform = ref(null)
  239. const treeListData = ref([])
  240. const formConfig = computed(() => {
  241. return [
  242. {
  243. type: 'select',
  244. label: '功能模块',
  245. prop: 'titleTemplate',
  246. isLoad: {
  247. url: `/flowInfo/getClassifyList`,
  248. labelKey: 'stringArray',
  249. labelVal: 'stringArray',
  250. method: 'post',
  251. resUrl: '',
  252. },
  253. fn: (data) => {
  254. getFlowList(data)
  255. },
  256. },
  257. {
  258. type: 'select',
  259. label: '流程名称',
  260. prop: 'flowInfoId',
  261. data:[],
  262. },
  263. ]
  264. })
  265. const getFlowList = (name) => {
  266. proxy.post('/flowInfo/page',{
  267. pageNum:1,
  268. pageSize:1000,
  269. status: 1,
  270. classifyName:name
  271. }).then((message) => {
  272. formConfig.value[1].data = message.rows.map(item => {
  273. return {
  274. label:item.flowName,
  275. value:item.id
  276. }
  277. })
  278. })
  279. }
  280. const newPassword = () => {
  281. formData.data.password = generatePassword()
  282. }
  283. const generatePassword = () => {
  284. var length = 12,
  285. charset =
  286. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
  287. password = ''
  288. for (var i = 0, n = charset.length; i < length; ++i) {
  289. password += charset.charAt(Math.floor(Math.random() * n))
  290. }
  291. return password
  292. }
  293. const getTreeList = () => {
  294. proxy.post('/tenantInfo/list').then((message) => {
  295. message.map((item) => {
  296. item.label = item.enterpriseName
  297. item.id = item.tenantId
  298. item.children = []
  299. })
  300. treeListData.value = message
  301. console.log(treeListData.value)
  302. })
  303. }
  304. const getList = async (req) => {
  305. sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
  306. loading.value = true
  307. proxy
  308. .post('/flowDefinition/page', sourceList.value.pagination)
  309. .then((message) => {
  310. sourceList.value.data = message.rows
  311. sourceList.value.pagination.total = message.total
  312. setTimeout(() => {
  313. loading.value = false
  314. }, 200)
  315. })
  316. }
  317. const treeChange = (e) => {
  318. console.log(e)
  319. sourceList.value.pagination.tenantId = e.id
  320. getList({ tenantId: e.id })
  321. }
  322. const openModal = () => {
  323. dialogVisible.value = true
  324. modalType.value = 'add'
  325. formData.data = {
  326. userType: 1,
  327. }
  328. }
  329. const TreetenantId = ref('')
  330. const selection = ref({
  331. data: [],
  332. })
  333. const select = (_selection, row) => {
  334. selection.value.data = _selection
  335. console.log(_selection.length)
  336. }
  337. const tree = ref(null)
  338. const submitForm = () => {
  339. byform.value.handleSubmit((valid) => {
  340. proxy
  341. .post(
  342. '/flowDefinition/' + modalType.value,
  343. {
  344. ...formData.data,
  345. tenantId: sourceList.value.pagination.tenantId,
  346. },
  347. )
  348. .then((res) => {
  349. ElMessage({
  350. message: modalType.value == 'add' ? '添加成功' : '编辑成功',
  351. type: 'success',
  352. })
  353. dialogVisible.value = false
  354. getList()
  355. })
  356. })
  357. }
  358. const getDept = () => {
  359. proxy.get('/system/user/deptTree').then((res) => {
  360. //formConfig.value[0].data = res.data
  361. })
  362. }
  363. const router = useRouter();
  364. const getDtl = (row) => {
  365. formData.data = { ...row }
  366. router.push({
  367. path: 'processChart',
  368. query: {
  369. id: row.id,
  370. flowInfoId:row.flowInfoId,
  371. tenantId:row.tenantId
  372. },
  373. })
  374. }
  375. getTreeList()
  376. getList()
  377. </script>
  378. <style lang="scss" scoped>
  379. .user {
  380. padding: 20px;
  381. display: flex;
  382. justify-content: space-between;
  383. .tree {
  384. width: 300px;
  385. }
  386. .content {
  387. width: calc(100% - 320px);
  388. }
  389. }
  390. </style>