index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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="800"
  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">取 消</el-button>
  45. <el-button
  46. type="primary"
  47. @click="submitForm('byform')"
  48. size="large"
  49. :loading="submitLoading"
  50. >
  51. 确 定
  52. </el-button>
  53. </template>
  54. </el-dialog>
  55. </div>
  56. </template>
  57. <script setup>
  58. /* eslint-disable vue/no-unused-components */
  59. import { ElMessage, ElMessageBox } from "element-plus";
  60. import byTable from "@/components/byTable/index";
  61. import byForm from "@/components/byForm/index";
  62. import { computed, defineComponent, ref } from "vue";
  63. const loading = ref(false);
  64. const submitLoading = ref(false);
  65. const sourceList = ref({
  66. data: [],
  67. pagination: {
  68. total: 3,
  69. pageNum: 1,
  70. pageSize: 10,
  71. },
  72. });
  73. let dialogVisible = ref(false);
  74. let roomDialogVisible = ref(false);
  75. let modalType = ref("add");
  76. let rules = ref({
  77. name: [{ required: true, message: "请选择车间名称", trigger: "change" }],
  78. name: [{ required: true, message: "请选择产线类型", trigger: "change" }],
  79. endPoint: [{ required: true, message: "请输入产线名称", trigger: "blur" }],
  80. });
  81. const { proxy } = getCurrentInstance();
  82. const selectConfig = computed(() => {
  83. return [
  84. {
  85. label: "车间",
  86. prop: "flowStatus",
  87. data: [
  88. {
  89. label: "审核中",
  90. value: "1",
  91. },
  92. {
  93. label: "审核通过",
  94. value: "2",
  95. },
  96. {
  97. label: "审核不通过",
  98. value: "3",
  99. },
  100. ],
  101. },
  102. {
  103. label: "产线类型",
  104. prop: "flowStatus",
  105. data: [
  106. {
  107. label: "审核中",
  108. value: "1",
  109. },
  110. {
  111. label: "审核通过",
  112. value: "2",
  113. },
  114. {
  115. label: "审核不通过",
  116. value: "3",
  117. },
  118. ],
  119. },
  120. ];
  121. });
  122. const config = computed(() => {
  123. return [
  124. {
  125. attrs: {
  126. label: "车间名称",
  127. prop: "type",
  128. width: 120,
  129. render(type) {
  130. return "华为";
  131. },
  132. },
  133. },
  134. {
  135. attrs: {
  136. label: "产线类型",
  137. prop: "name",
  138. width: 150,
  139. },
  140. },
  141. {
  142. attrs: {
  143. label: "产线名称",
  144. prop: "endPoint",
  145. width: 100,
  146. },
  147. },
  148. {
  149. attrs: {
  150. label: "负责人",
  151. prop: "endPoint",
  152. width: 100,
  153. },
  154. },
  155. {
  156. attrs: {
  157. label: "产线说明",
  158. prop: "accessKeyId",
  159. },
  160. },
  161. {
  162. attrs: {
  163. label: "操作",
  164. width: "200",
  165. align: "right",
  166. },
  167. // 渲染 el-button,一般用在最后一列。
  168. renderHTML(row) {
  169. return [
  170. {
  171. attrs: {
  172. label: "修改",
  173. type: "primary",
  174. text: true,
  175. },
  176. el: "button",
  177. click() {
  178. getDtl(row);
  179. },
  180. },
  181. {
  182. attrs: {
  183. label: "删除",
  184. type: "danger",
  185. text: true,
  186. },
  187. el: "button",
  188. click() {
  189. // 弹窗提示是否删除
  190. ElMessageBox.confirm(
  191. "此操作将永久删除该数据, 是否继续?",
  192. "提示",
  193. {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning",
  197. }
  198. ).then(() => {
  199. // 删除
  200. proxy
  201. .post("/tdaConfig/delete", {
  202. id: row.id,
  203. })
  204. .then((res) => {
  205. ElMessage({
  206. message: "删除成功",
  207. type: "success",
  208. });
  209. getList();
  210. });
  211. });
  212. },
  213. },
  214. ];
  215. },
  216. },
  217. ];
  218. });
  219. let formData = reactive({
  220. data: {
  221. type: "1",
  222. },
  223. treeData: [],
  224. });
  225. const formOption = reactive({
  226. inline: true,
  227. labelWidth: 100,
  228. itemWidth: 100,
  229. rules: [],
  230. });
  231. const byform = ref(null);
  232. const treeData = ref([]);
  233. const formConfig = computed(() => {
  234. return [
  235. {
  236. type: "select",
  237. prop: "name",
  238. label: "车间名称",
  239. required: true,
  240. data: [],
  241. },
  242. {
  243. type: "select",
  244. prop: "name",
  245. label: "产线类型",
  246. required: true,
  247. data: [],
  248. },
  249. {
  250. type: "input",
  251. prop: "aa",
  252. label: "产线名称",
  253. required: true,
  254. },
  255. {
  256. type: "select",
  257. prop: "name",
  258. label: "负责人",
  259. data: [],
  260. },
  261. {
  262. type: "input",
  263. prop: "secretAccessKey",
  264. label: "产线说明",
  265. itemType: "textarea",
  266. },
  267. ];
  268. });
  269. const getList = async (req) => {
  270. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  271. loading.value = true;
  272. proxy.post("/tdaConfig/page", sourceList.value.pagination).then((message) => {
  273. console.log(message);
  274. sourceList.value.data = message.rows;
  275. sourceList.value.pagination.total = message.total;
  276. setTimeout(() => {
  277. loading.value = false;
  278. }, 200);
  279. });
  280. };
  281. const openModal = () => {
  282. dialogVisible.value = true;
  283. modalType.value = "add";
  284. formData.data = {};
  285. };
  286. const selection = ref({
  287. data: [],
  288. });
  289. const select = (_selection, row) => {
  290. selection.value.data = _selection;
  291. console.log(_selection.length);
  292. };
  293. const submitForm = () => {
  294. console.log(byform.value);
  295. byform.value.handleSubmit((valid) => {
  296. submitLoading.value = true;
  297. proxy.post("/tdaConfig/" + modalType.value, formData.data).then((res) => {
  298. ElMessage({
  299. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  300. type: "success",
  301. });
  302. dialogVisible.value = false;
  303. submitLoading.value = false;
  304. getList();
  305. });
  306. });
  307. };
  308. const getDtl = (row) => {
  309. modalType = "edit";
  310. proxy.post("/tdaConfig/detail", { id: row.id }).then((res) => {
  311. formData.data = res;
  312. console.log(formData);
  313. dialogVisible.value = true;
  314. });
  315. };
  316. // getList();
  317. </script>
  318. <style lang="scss" scoped>
  319. .tenant {
  320. padding: 20px;
  321. }
  322. </style>