diff --git a/src/icons/svg/导出.svg b/src/icons/svg/导出.svg new file mode 100644 index 0000000..1dab8db --- /dev/null +++ b/src/icons/svg/导出.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/src/icons/svg/转让状态.svg b/src/icons/svg/转让状态.svg new file mode 100644 index 0000000..3cc7cb7 --- /dev/null +++ b/src/icons/svg/转让状态.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/src/mixins/basic-add.js b/src/mixins/basic-add.js new file mode 100644 index 0000000..6ebc3ad --- /dev/null +++ b/src/mixins/basic-add.js @@ -0,0 +1,96 @@ +/* + * @Author: zwq + * @Date: 2022-08-24 11:19:43 + * @LastEditors: zwq + * @LastEditTime: 2022-08-26 15:38:58 + * @Description: + */ +export default { + data() { + /* eslint-disable */ + return { + urlOptions: { + submitURL: '', + infoURL: '', + getOption: false, + optionArrUrl: [], + optionArr: {} + }, + visible: false, + setData:false + } + }, + created() { + }, + activated() { + }, + methods: { + init(id) { + this.dataForm.id = id || ""; + this.visible = true; + if (this.urlOptions.getOption) { + this.getArr() + } + this.$nextTick(() => { + this.$refs["dataForm"].resetFields(); + if (this.dataForm.id) { + this.$http + .get(`${this.urlOptions.infoURL}/${this.dataForm.id}`) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg); + } + this.dataForm = res.data; + if(this.setData){ + this.setDataForm() + } + }) + .catch(() => { }); + } + }); + }, + getArr() { + this.urlOptions.optionArrUrl.forEach((item, index) => { + this.$http + .get(item, { + params: { + page: 1, + limit: 500, + }, + }) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg); + } + this.$set(this.urlOptions.optionArr, `arr${index}`, res.data.list) + }) + .catch(() => { + }); + }); + }, + // 表单提交 + dataFormSubmit() { + this.$refs["dataForm"].validate((valid) => { + if (!valid) { + return false; + } + this.$http[!this.dataForm.id ? "post" : "put"](this.urlOptions.submitURL, this.dataForm) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg); + } + this.$message({ + message: this.$t("prompt.success"), + type: "success", + duration: 500, + onClose: () => { + this.visible = false; + this.$emit("refreshDataList"); + }, + }); + }) + .catch(() => { }); + }); + }, + } +} \ No newline at end of file diff --git a/src/mixins/basic-page.js b/src/mixins/basic-page.js new file mode 100644 index 0000000..8000526 --- /dev/null +++ b/src/mixins/basic-page.js @@ -0,0 +1,156 @@ +/* + * @Author: zwq + * @Date: 2022-08-24 11:19:43 + * @LastEditors: zwq + * @LastEditTime: 2022-08-24 14:06:58 + * @Description: + */ +export default { + data () { + /* eslint-disable */ + return { + urlOptions: { + getDataListURL: '', + deleteURL: '', + statusUrl: '', + exportUrl: '' + }, + dataForm: { + paramKey: "", + }, + dataList: [], + pageIndex: 1, + pageSize: 10, + totalPage: 0, + dataListLoading: false, + addOrUpdateVisible: false, + } + }, + created () { + }, + activated() { + this.getDataList(); + }, + methods: { + + // 获取数据列表 + getDataList() { + this.dataListLoading = true; + this.$http + .get(this.urlOptions.getDataListURL, { + params: { + page: this.pageIndex, + limit: this.pageSize, + code: this.dataForm.paramKey, + name: this.dataForm.paramKey, + }, + }) + .then(({ data: res }) => { + this.dataListLoading = false; + if (res.code !== 0) { + this.dataList = []; + this.totalPage = 0; + return this.$message.error(res.msg); + } + this.dataList = res.data.list; + this.totalPage = res.data.total; + }) + .catch(() => { + this.dataListLoading = false; + }); + }, + // 每页数 + sizeChangeHandle(val) { + this.pageSize = val; + this.pageIndex = 1; + this.getDataList(); + }, + // 当前页 + currentChangeHandle(val) { + this.pageIndex = val; + this.getDataList(); + }, + // 新增 / 修改 + addOrUpdateHandle(id) { + this.addOrUpdateVisible = true; + this.$nextTick(() => { + this.$refs.addOrUpdate.init(id); + }); + }, + cancel(id) { + this.$refs["popover-" + id].showPopper = false; + }, + changeStatus(id) { + this.$http + .post(this.urlOptions.statusUrl, { id }) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg); + } + this.$refs["popover-" + id].showPopper = false; + this.$message({ + message: this.$t("prompt.success"), + type: "success", + duration: 500, + onClose: () => { + this.getDataList(); + }, + }); + }) + .catch(() => {}); + }, + // 删除 + deleteHandle(id, name) { + this.$confirm(`确定对[名称=${name}]进行删除操作?`, "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + this.$http.delete(this.urlOptions.deleteURL, { data: [id] }).then(({ data }) => { + if (data && data.code === 0) { + this.$message({ + message: "操作成功", + type: "success", + duration: 1500, + onClose: () => { + this.getDataList(); + }, + }); + } else { + this.$message.error(data.msg); + } + }); + }) + .catch(() => {}); + }, + // 导出 + exportHandle(name) { + this.$http + .get(this.urlOptions.exportUrl, { responseType: "blob" }) + .then(({ data: res }) => { + var date = new Date(); + var year = date.getFullYear(); + var month = date.getMonth() + 1; + var strDate = date.getDate(); + if (month >= 1 && month <= 9) { + month = "0" + month; + } + if (strDate >= 0 && strDate <= 9) { + strDate = "0" + strDate; + } + var currentdate = year + "-" + month + "-" + strDate; + const blob = new Blob([res]); + const downloadElement = document.createElement("a"); + const href = window.URL.createObjectURL(blob); // 创建下载的链接 + downloadElement.href = href; + downloadElement.download = `${name+currentdate}.xls`; // 下载后文件名 + document.body.appendChild(downloadElement); + downloadElement.click(); // 点击下载 + document.body.removeChild(downloadElement); // 下载完成移除元素 + window.URL.revokeObjectURL(href); + }) + .catch(() => {}); + } + } +} \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index abd1405..1fa8d9d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -43,8 +43,8 @@ export const moduleRoutes = { { path: '/processFlow', component: () => import('@/views/spc-basic/processFlow'), name: 'processFlow', meta: { title: '工艺流程', isTab: true } }, { path: '/siteManage', component: () => import('@/views/spc-basic/siteManage'), name: 'siteManage', meta: { title: '站点管理', isTab: true } }, { path: '/machineManage', component: () => import('@/views/spc-basic/machineManage'), name: 'machineManage', meta: { title: '机台管理', isTab: true } }, - { path: '/toolsType', component: () => import('@/views/spc-basic/toolsType'), name: 'toolsType', meta: { title: '量具类型', isTab: true } }, - { path: '/unitList', component: () => import('@/views/spc-basic/unitList'), name: 'unitList', meta: { title: '计量单位列表', isTab: true } } + { path: '/toolsType', component: () => import('@/views/spc-basic/toolsType'), name: 'toolsType', meta: { title: '量具管理', isTab: true } }, + { path: '/unitList', component: () => import('@/views/spc-basic/unitList'), name: 'unitList', meta: { title: '计量单位管理', isTab: true } } ] } diff --git a/src/views/main-sidebar.vue b/src/views/main-sidebar.vue index c4894f0..2510ac6 100644 --- a/src/views/main-sidebar.vue +++ b/src/views/main-sidebar.vue @@ -65,11 +65,11 @@ - 量具类型 + 量具管理 - 计量单位列表 + 计量单位管理 diff --git a/src/views/pages/login.vue b/src/views/pages/login.vue index 3f03233..885a2bc 100644 --- a/src/views/pages/login.vue +++ b/src/views/pages/login.vue @@ -58,7 +58,7 @@ export default { return { captchaPath: '', dataForm: { - username: 'admin', + username: 'admin1', password: 'admin', uuid: '', captcha: '' diff --git a/src/views/spc-basic/components/factoryManage-add.vue b/src/views/spc-basic/components/factoryManage-add.vue index 8442c52..a386168 100644 --- a/src/views/spc-basic/components/factoryManage-add.vue +++ b/src/views/spc-basic/components/factoryManage-add.vue @@ -2,7 +2,7 @@ * @Author: zwq * @Date: 2021-11-18 14:16:25 * @LastEditors: zwq - * @LastEditTime: 2022-08-12 15:37:44 + * @LastEditTime: 2022-08-24 14:10:21 * @Description: --> - - + + + - + --> - + @@ -151,96 +182,23 @@ + }, +}; + \ No newline at end of file diff --git a/src/views/spc-basic/productType.vue b/src/views/spc-basic/productType.vue index 06a4a0e..056a1cc 100644 --- a/src/views/spc-basic/productType.vue +++ b/src/views/spc-basic/productType.vue @@ -10,18 +10,25 @@ - + 查询 - + 新增 + + + + + 导出 + - + - - + + - + @@ -109,100 +110,24 @@ diff --git a/src/views/spc-basic/siteManage.vue b/src/views/spc-basic/siteManage.vue index 7bfa36d..6a5fe2a 100644 --- a/src/views/spc-basic/siteManage.vue +++ b/src/views/spc-basic/siteManage.vue @@ -10,18 +10,25 @@ - + 查询 - + 新增 + + + + + 导出 + - + - + @@ -110,96 +138,23 @@ + }, +}; + \ No newline at end of file diff --git a/src/views/spc-basic/toolsType.vue b/src/views/spc-basic/toolsType.vue index 05b9fa2..e9cc3ca 100644 --- a/src/views/spc-basic/toolsType.vue +++ b/src/views/spc-basic/toolsType.vue @@ -10,18 +10,25 @@ - + 查询 - + 新增 + + + + + 导出 + @@ -69,7 +76,7 @@ fixed="right" header-align="center" align="center" - width="150" + width="200" label="操作" > @@ -125,115 +155,42 @@ ref="addOrUpdate" @refreshDataList="getDataList" > - + > diff --git a/src/views/spc-basic/unitList.vue b/src/views/spc-basic/unitList.vue index 02fe3be..25116ce 100644 --- a/src/views/spc-basic/unitList.vue +++ b/src/views/spc-basic/unitList.vue @@ -10,18 +10,25 @@ - + 查询 - + 新增 + + + + + 导出 + @@ -87,11 +94,32 @@ - + @@ -116,96 +144,23 @@