index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. :action-list="[
  17. {
  18. text: '添加',
  19. action: () => openModal('add'),
  20. },
  21. ]"
  22. @get-list="getList"
  23. >
  24. <template #slotName="{ item }">
  25. {{ item.createTime }}
  26. </template>
  27. </byTable>
  28. </div>
  29. <el-dialog
  30. :title="modalType == 'add' ? '新增' : '编辑'"
  31. v-model="dialogVisible"
  32. width="400"
  33. v-loading="loading"
  34. >
  35. <byForm
  36. :formConfig="formConfig"
  37. :formOption="formOption"
  38. v-model="formData.data"
  39. :rules="rules"
  40. ref="byform"
  41. >
  42. </byForm>
  43. <template #footer>
  44. <el-button @click="dialogVisible = false" size="large"
  45. >取 消</el-button
  46. >
  47. <el-button
  48. type="primary"
  49. @click="submitForm('byform')"
  50. size="large"
  51. :loading="submitLoading"
  52. >
  53. 确 定
  54. </el-button>
  55. </template>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script setup>
  60. /* eslint-disable vue/no-unused-components */
  61. import { ElMessage, ElMessageBox } from 'element-plus'
  62. import byTable from '@/components/byTable/index'
  63. import byForm from '@/components/byForm/index'
  64. import { computed, defineComponent, ref } from 'vue'
  65. const loading = ref(false)
  66. const submitLoading = ref(false)
  67. const dictCommonModal = ref(false)
  68. const sourceList = ref({
  69. data: [],
  70. pagination: {
  71. total: 3,
  72. pageNum: 1,
  73. pageSize: 10,
  74. },
  75. })
  76. let dialogVisible = ref(false)
  77. let roomDialogVisible = ref(false)
  78. let modalType = ref('add')
  79. let rules = ref({
  80. classifyName: [{ required: true, message: '请输入功能模块', trigger: 'blur' }],
  81. flowKey: [{ required: true, message: '请输入流程标识', trigger: 'blur' }],
  82. flowName: [{ required: true, message: '请输入流程名称', trigger: 'blur' },],
  83. })
  84. const { proxy } = getCurrentInstance()
  85. const selectConfig = computed(() => {
  86. return []
  87. })
  88. const config = computed(() => {
  89. return [
  90. {
  91. attrs: {
  92. label: '功能模块',
  93. prop: 'classifyName',
  94. },
  95. },
  96. {
  97. attrs: {
  98. label: '流程标识',
  99. prop: 'flowKey',
  100. },
  101. },
  102. {
  103. attrs: {
  104. label: '流程名称',
  105. prop: 'flowName',
  106. },
  107. },
  108. {
  109. attrs: {
  110. label: '状态',
  111. width: 100,
  112. prop: 'status',
  113. },
  114. render(status) {
  115. //1审核中 2审核通过 3审核不通过
  116. return status == 0
  117. ? '禁用'
  118. : '启用'
  119. },
  120. },
  121. {
  122. attrs: {
  123. label: '创建时间',
  124. prop: 'createTime',
  125. },
  126. },
  127. {
  128. attrs: {
  129. label: '操作',
  130. width: '200',
  131. align: 'right',
  132. },
  133. // 渲染 el-button,一般用在最后一列。
  134. renderHTML(row) {
  135. return [
  136. {
  137. attrs: {
  138. label: "修改",
  139. type: "primary",
  140. text: true,
  141. },
  142. el: "button",
  143. click() {
  144. getDtl(row);
  145. },
  146. },
  147. {
  148. attrs: {
  149. label: row.status == 1 ? '禁用' : '启用',
  150. type: 'primary',
  151. text: true,
  152. },
  153. el: 'button',
  154. click() {
  155. changeStatus(row)
  156. },
  157. },
  158. ]
  159. },
  160. },
  161. ]
  162. })
  163. let dtlData = reactive({
  164. data: {},
  165. })
  166. let formData = reactive({
  167. data: {},
  168. treeData: [],
  169. })
  170. const formOption = reactive({
  171. inline: true,
  172. labelWidth: 100,
  173. itemWidth: 100,
  174. rules: [],
  175. })
  176. const byform = ref(null)
  177. const treeData = ref([])
  178. const formConfig = computed(() => {
  179. return [
  180. {
  181. type: 'input',
  182. prop: 'classifyName',
  183. label: '功能模块',
  184. },
  185. {
  186. type: 'input',
  187. prop: 'flowKey',
  188. label: '流程标识',
  189. isHide:modalType.value == 'edit'
  190. },
  191. {
  192. type: 'input',
  193. prop: 'flowName',
  194. label: '流程名称',
  195. },
  196. ]
  197. })
  198. const getList = async (req) => {
  199. sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
  200. loading.value = true
  201. proxy
  202. .post('/flowInfo/page', sourceList.value.pagination)
  203. .then((message) => {
  204. sourceList.value.data = message.rows
  205. sourceList.value.pagination.total = message.total
  206. setTimeout(() => {
  207. loading.value = false
  208. }, 200)
  209. })
  210. }
  211. const openModal = () => {
  212. dialogVisible.value = true
  213. modalType.value = 'add'
  214. formData.data = {}
  215. }
  216. const selection = ref({
  217. data: [],
  218. })
  219. const select = (_selection, row) => {
  220. selection.value.data = _selection
  221. }
  222. const tree = ref(null)
  223. const submitTree = () => {
  224. proxy
  225. .post('/tenantInfo/bindingMenu', {
  226. tenantId: selection.value.data[0].tenantId,
  227. menuIdList: tree.value.getCheckedKeys(),
  228. })
  229. .then((res) => {
  230. ElMessage({
  231. message: '保存成功',
  232. type: 'success',
  233. })
  234. roomDialogVisible.value = false
  235. })
  236. }
  237. const submitForm = () => {
  238. byform.value.handleSubmit((valid) => {
  239. submitLoading.value = true
  240. proxy
  241. .post('/flowInfo/' + modalType.value, formData.data)
  242. .then((res) => {
  243. ElMessage({
  244. message: modalType.value == 'add' ? '添加成功' : '编辑成功',
  245. type: 'success',
  246. })
  247. dialogVisible.value = false
  248. submitLoading.value = false
  249. getList()
  250. })
  251. })
  252. }
  253. const getDtl = (row) => {
  254. formData.data = { ...row }
  255. modalType.value = 'edit'
  256. dialogVisible.value = true
  257. }
  258. const changeStatus = (row) => {
  259. modalType.value = 'edit'
  260. proxy.post('/flowInfo/edit', { ...row,status:(row.status === 0) ? 1 : 0 }).then((res) => {
  261. ElMessage({
  262. message: '操作成功',
  263. type: 'success',
  264. })
  265. getList()
  266. })
  267. }
  268. getList()
  269. </script>
  270. <style lang="scss" scoped>
  271. .tenant {
  272. padding: 20px;
  273. }
  274. </style>