diff --git a/src/plugins/modal.js b/src/plugins/modal.js index b37ca14..eb24159 100644 --- a/src/plugins/modal.js +++ b/src/plugins/modal.js @@ -1,83 +1,87 @@ import { Message, MessageBox, Notification, Loading } from 'element-ui' -let loadingInstance; +let loadingInstance export default { - // 消息提示 - msg(content) { - Message.info(content) - }, - // 错误消息 - msgError(content) { - Message.error(content) - }, - // 成功消息 - msgSuccess(content) { - Message.success(content) - }, - // 警告消息 - msgWarning(content) { - Message.warning(content) - }, - // 弹出提示 - alert(content) { - MessageBox.alert(content, "系统提示") - }, - // 错误提示 - alertError(content) { - MessageBox.alert(content, "系统提示", { type: 'error' }) - }, - // 成功提示 - alertSuccess(content) { - MessageBox.alert(content, "系统提示", { type: 'success' }) - }, - // 警告提示 - alertWarning(content) { - MessageBox.alert(content, "系统提示", { type: 'warning' }) - }, - // 通知提示 - notify(content) { - Notification.info(content) - }, - // 错误通知 - notifyError(content) { - Notification.error(content); - }, - // 成功通知 - notifySuccess(content) { - Notification.success(content) - }, - // 警告通知 - notifyWarning(content) { - Notification.warning(content) - }, - // 确认窗体 - confirm(content) { - return MessageBox.confirm(content, "系统提示", { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: "warning", - }) - }, - // 提交内容 - prompt(content) { - return MessageBox.prompt(content, "系统提示", { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: "warning", - }) - }, - // 打开遮罩层 - loading(content) { - loadingInstance = Loading.service({ - lock: true, - text: content, - spinner: "el-icon-loading", - background: "rgba(0, 0, 0, 0.7)", - }) - }, - // 关闭遮罩层 - closeLoading() { - loadingInstance.close(); - } + // 消息提示 + msg(content) { + Message.closeAll() + Message.info(content) + }, + // 错误消息 + msgError(content) { + Message.closeAll() + Message.error(content) + }, + // 成功消息 + msgSuccess(content) { + Message.closeAll() + Message.success(content) + }, + // 警告消息 + msgWarning(content) { + Message.closeAll() + Message.warning(content) + }, + // 弹出提示 + alert(content) { + MessageBox.alert(content, '系统提示') + }, + // 错误提示 + alertError(content) { + MessageBox.alert(content, '系统提示', { type: 'error' }) + }, + // 成功提示 + alertSuccess(content) { + MessageBox.alert(content, '系统提示', { type: 'success' }) + }, + // 警告提示 + alertWarning(content) { + MessageBox.alert(content, '系统提示', { type: 'warning' }) + }, + // 通知提示 + notify(content) { + Notification.info(content) + }, + // 错误通知 + notifyError(content) { + Notification.error(content) + }, + // 成功通知 + notifySuccess(content) { + Notification.success(content) + }, + // 警告通知 + notifyWarning(content) { + Notification.warning(content) + }, + // 确认窗体 + confirm(content) { + return MessageBox.confirm(content, '系统提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + }, + // 提交内容 + prompt(content) { + return MessageBox.prompt(content, '系统提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + }, + // 打开遮罩层 + loading(content) { + loadingInstance = Loading.service({ + lock: true, + text: content, + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)', + }) + }, + // 关闭遮罩层 + closeLoading() { + loadingInstance.close() + }, } diff --git a/src/utils/request.js b/src/utils/request.js index 96a1165..8453555 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,179 +3,244 @@ import { Notification, MessageBox, Message, Loading } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' import errorCode from '@/utils/errorCode' -import { tansParams, blobValidate } from "@/utils/ruoyi"; +import { tansParams, blobValidate } from '@/utils/ruoyi' import cache from '@/plugins/cache' import { saveAs } from 'file-saver' -let downloadLoadingInstance; +let downloadLoadingInstance // 是否显示重新登录 -export let isRelogin = { show: false }; +export let isRelogin = { show: false } axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 const service = axios.create({ - // axios中请求配置有baseURL选项,表示请求URL公共部分 - baseURL: process.env.VUE_APP_BASE_API, - // 超时 - timeout: 10000 + // axios中请求配置有baseURL选项,表示请求URL公共部分 + baseURL: process.env.VUE_APP_BASE_API, + // 超时 + timeout: 10000, }) // request拦截器 -service.interceptors.request.use(config => { - // 是否需要设置 token - const isToken = (config.headers || {}).isToken === false - // 是否需要防止数据重复提交 - const isRepeatSubmit = (config.headers || {}).repeatSubmit === false - if (getToken() && !isToken) { - config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - } - // get请求映射params参数 - if (config.method === 'get' && config.params) { - let url = config.url + '?' + tansParams(config.params); - url = url.slice(0, -1); - config.params = {}; - config.url = url; - } - if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { - const requestObj = { - url: config.url, - data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data, - time: new Date().getTime() - } - const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 请求数据大小 - const limitSize = 5 * 1024 * 1024; // 限制存放数据5M - if (requestSize >= limitSize) { - console.warn(`[${config.url}]: ` + '请求数据大小超出允许的5M限制,无法进行防重复提交验证。') - return config; - } - const sessionObj = cache.session.getJSON('sessionObj') - if (sessionObj === undefined || sessionObj === null || sessionObj === '') { - cache.session.setJSON('sessionObj', requestObj) - } else { - const s_url = sessionObj.url; // 请求地址 - const s_data = sessionObj.data; // 请求数据 - const s_time = sessionObj.time; // 请求时间 - const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 - if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { - const message = '数据正在处理,请勿重复提交'; - console.warn(`[${s_url}]: ` + message) - return Promise.reject(new Error(message)) - } else { - cache.session.setJSON('sessionObj', requestObj) - } - } - } - return config -}, error => { - console.log(error) - Promise.reject(error) -}) +service.interceptors.request.use( + (config) => { + // 是否需要设置 token + const isToken = (config.headers || {}).isToken === false + // 是否需要防止数据重复提交 + const isRepeatSubmit = (config.headers || {}).repeatSubmit === false + if (getToken() && !isToken) { + config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + } + // get请求映射params参数 + if (config.method === 'get' && config.params) { + let url = config.url + '?' + tansParams(config.params) + url = url.slice(0, -1) + config.params = {} + config.url = url + } + if ( + !isRepeatSubmit && + (config.method === 'post' || config.method === 'put') + ) { + const requestObj = { + url: config.url, + data: + typeof config.data === 'object' + ? JSON.stringify(config.data) + : config.data, + time: new Date().getTime(), + } + const requestSize = Object.keys(JSON.stringify(requestObj)).length // 请求数据大小 + const limitSize = 5 * 1024 * 1024 // 限制存放数据5M + if (requestSize >= limitSize) { + console.warn( + `[${config.url}]: ` + + '请求数据大小超出允许的5M限制,无法进行防重复提交验证。', + ) + return config + } + const sessionObj = cache.session.getJSON('sessionObj') + if ( + sessionObj === undefined || + sessionObj === null || + sessionObj === '' + ) { + cache.session.setJSON('sessionObj', requestObj) + } else { + const s_url = sessionObj.url // 请求地址 + const s_data = sessionObj.data // 请求数据 + const s_time = sessionObj.time // 请求时间 + const interval = 1000 // 间隔时间(ms),小于此时间视为重复提交 + if ( + s_data === requestObj.data && + requestObj.time - s_time < interval && + s_url === requestObj.url + ) { + const message = '数据正在处理,请勿重复提交' + console.warn(`[${s_url}]: ` + message) + return Promise.reject(new Error(message)) + } else { + cache.session.setJSON('sessionObj', requestObj) + } + } + } + return config + }, + (error) => { + console.log(error) + Promise.reject(error) + }, +) // 响应拦截器 -service.interceptors.response.use(res => { - // 未设置状态码则默认成功状态 - const code = res.data.code || 200; - // 获取错误信息 - const msg = errorCode[code] || res.data.msg || errorCode['default'] - // 二进制数据则直接返回 - if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { - return res.data - } - if (code === 401) { - if (!isRelogin.show) { - isRelogin.show = true; - MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => { - isRelogin.show = false; - store.dispatch('LogOut').then(() => { - // location.href = '/login'; - // location.href = '/gl/login'; +service.interceptors.response.use( + (res) => { + // 未设置状态码则默认成功状态 + const code = res.data.code || 200 + // 获取错误信息 + const msg = errorCode[code] || res.data.msg || errorCode['default'] + // 二进制数据则直接返回 + if ( + res.request.responseType === 'blob' || + res.request.responseType === 'arraybuffer' + ) { + return res.data + } + if (code === 401) { + if (!isRelogin.show) { + isRelogin.show = true + MessageBox.confirm( + '登录状态已过期,您可以继续留在该页面,或者重新登录', + '系统提示', + { + confirmButtonText: '重新登录', + cancelButtonText: '取消', + type: 'warning', + }, + ) + .then(() => { + isRelogin.show = false + store.dispatch('LogOut').then(() => { + // location.href = '/login'; + // location.href = '/gl/login'; - location.href = process.env.VUE_APP_ENV === 'production-nw' ? '/sgzbgl/login' : '/login' - }) - }).catch(() => { - isRelogin.show = false; - }); - } - return Promise.reject('无效的会话,或者会话已过期,请重新登录。') - } else if (code === 500) { - Message({ message: msg, type: 'error' }) - return Promise.reject(new Error(msg)) - } else if (code === 601) { - Message({ message: msg, type: 'warning' }) - return Promise.reject('error') - } else if (code !== 200) { - Notification.error({ title: msg }) - return Promise.reject('error') - } else { - return res.data - } -}, - error => { - console.log('err' + error) - let { message } = error; - if (message == "Network Error") { - message = "后端接口连接异常"; - } else if (message.includes("timeout")) { - message = "系统接口请求超时"; - } else if (message.includes("Request failed with status code")) { - message = "系统接口" + message.substr(message.length - 3) + "异常"; - } - Message({ message: message, type: 'error', duration: 5 * 1000 }) - return Promise.reject(error) - } + location.href = + process.env.VUE_APP_ENV === 'production-nw' + ? '/sgzbgl/login' + : '/login' + }) + }) + .catch(() => { + isRelogin.show = false + }) + } + return Promise.reject('无效的会话,或者会话已过期,请重新登录。') + } else if (code === 500) { + Message.closeAll() + Message({ message: msg, type: 'error' }) + return Promise.reject(new Error(msg)) + } else if (code === 601) { + Message.closeAll() + Message({ message: msg, type: 'warning' }) + return Promise.reject('error') + } else if (code !== 200) { + Notification.closeAll() + Notification.error({ title: msg }) + return Promise.reject('error') + } else { + return res.data + } + }, + (error) => { + console.log('err' + error) + let { message } = error + if (message == 'Network Error') { + message = '后端接口连接异常' + } else if (message.includes('timeout')) { + message = '系统接口请求超时' + } else if (message.includes('Request failed with status code')) { + message = '系统接口' + message.substr(message.length - 3) + '异常' + } + Message.closeAll() + Message({ message: message, type: 'error', duration: 5 * 1000 }) + return Promise.reject(error) + }, ) // 通用下载方法 export function download(url, params, filename, config) { - downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) - return service.post(url, params, { - transformRequest: [(params) => { return tansParams(params) }], - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - responseType: 'blob', - ...config - }).then(async (data) => { - const isBlob = blobValidate(data); - if (isBlob) { - const blob = new Blob([data]) - saveAs(blob, filename) - } else { - const resText = await data.text(); - const rspObj = JSON.parse(resText); - const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] - Message.error(errMsg); - } - downloadLoadingInstance.close(); - }).catch((r) => { - console.error(r) - Message.error('下载文件出现错误,请联系管理员!') - downloadLoadingInstance.close(); - }) + downloadLoadingInstance = Loading.service({ + text: '正在下载数据,请稍候', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)', + }) + return service + .post(url, params, { + transformRequest: [ + (params) => { + return tansParams(params) + }, + ], + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + responseType: 'blob', + ...config, + }) + .then(async (data) => { + const isBlob = blobValidate(data) + if (isBlob) { + const blob = new Blob([data]) + saveAs(blob, filename) + } else { + const resText = await data.text() + const rspObj = JSON.parse(resText) + const errMsg = + errorCode[rspObj.code] || rspObj.msg || errorCode['default'] + Message.error(errMsg) + } + downloadLoadingInstance.close() + }) + .catch((r) => { + console.error(r) + Message.error('下载文件出现错误,请联系管理员!') + downloadLoadingInstance.close() + }) } // 通用下载方法 export function downloadJson(url, params, filename, config) { - downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) - return service.post(url, params, { - transformRequest: [(params) => { return params }], - headers: { 'Content-Type': 'application/json' }, - responseType: 'blob', - ...config - }).then(async (data) => { - const isBlob = blobValidate(data); - if (isBlob) { - const blob = new Blob([data]) - saveAs(blob, filename) - } else { - const resText = await data.text(); - const rspObj = JSON.parse(resText); - const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] - Message.error(errMsg); - } - downloadLoadingInstance.close(); - }).catch((r) => { - console.error(r) - Message.error('下载文件出现错误,请联系管理员!') - downloadLoadingInstance.close(); - }) + downloadLoadingInstance = Loading.service({ + text: '正在下载数据,请稍候', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)', + }) + return service + .post(url, params, { + transformRequest: [ + (params) => { + return params + }, + ], + headers: { 'Content-Type': 'application/json' }, + responseType: 'blob', + ...config, + }) + .then(async (data) => { + const isBlob = blobValidate(data) + if (isBlob) { + const blob = new Blob([data]) + saveAs(blob, filename) + } else { + const resText = await data.text() + const rspObj = JSON.parse(resText) + const errMsg = + errorCode[rspObj.code] || rspObj.msg || errorCode['default'] + Message.error(errMsg) + } + downloadLoadingInstance.close() + }) + .catch((r) => { + console.error(r) + Message.error('下载文件出现错误,请联系管理员!') + downloadLoadingInstance.close() + }) } export default service diff --git a/src/views/claimAndreturn/picking/apply/component/AddPicking1.vue b/src/views/claimAndreturn/picking/apply/component/AddPicking1.vue index 7b440bb..91dc336 100644 --- a/src/views/claimAndreturn/picking/apply/component/AddPicking1.vue +++ b/src/views/claimAndreturn/picking/apply/component/AddPicking1.vue @@ -75,13 +75,17 @@ @@ -457,11 +461,11 @@ export default { // 设备 树显示 配置 deviceTypeTreeProps: { - multiple: false, + multiple: true, value: 'id', }, // 选中的设备类型 - deviceType: null, + deviceType: [], // 表单参数 form: {}, @@ -495,6 +499,7 @@ export default { }, costBearingList: [], isCost: false, + propsKey: 1000, } }, mounted() { @@ -506,7 +511,7 @@ export default { this.getCostBearingFun() - this.GetDeviceTypeTree() + // this.GetDeviceTypeTree() // this.getList(); if (this.$route.query.taskId && !this.$route.query.isBack) { console.log('查看') @@ -521,8 +526,25 @@ export default { this.taskId = this.viewTaskId if (this.taskId) { - this.GetTaskDetail(this.taskId) + Promise.all([ + this.GetTaskDetail(this.taskId), + this.GetDeviceTypeTree(), + ]).then(() => { + let selectList = [] + this.leaseApplyDetails.forEach((e) => { + selectList.push( + this.getParentsById(this.deviceTypeTree, e.typeId), + ) + }) + this.$nextTick(() => { + this.deviceType = selectList + this.propsKey++ + }) + }) + } else { + this.GetDeviceTypeTree() } + // console.log(typeof(this.isEdit)) // this.$set('isEdit',this.$route.query.isEdit) }, @@ -560,8 +582,25 @@ export default { const params = { level: 4, } - const res = await getDeviceTypeTree(params) - this.deviceTypeTree = res.data + getDeviceTypeTree(params).then((res) => { + this.deviceTypeTree = res.data + }) + }, + getParentsById(list, id) { + for (let i in list) { + if (list[i].id == id) { + //查询到就返回该数组对象的value + return [list[i].id] + } + if (list[i].children) { + let node = this.getParentsById(list[i].children, id) + if (node !== undefined) { + //查询到把父节把父节点加到数组前面 + node.unshift(list[i].id) + return node + } + } + } }, // 获取 协议id async GetAgreementInfoById() { @@ -832,6 +871,12 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { + this.deviceType.forEach((e, index) => { + if (e[3] === row.typeId) { + this.deviceType.splice(index, 1) + this.propsKey++ + } + }) this.leaseApplyDetails.splice(row.index, 1) }, /** 导出按钮操作 */ @@ -851,25 +896,74 @@ export default { }, /////// 设备类型树 切换 deviceTypeChange(val) { - console.log(val) - let nodes = null - nodes = - this.$refs.deviceTypeCascader.getCheckedNodes().length > 0 - ? this.$refs.deviceTypeCascader.getCheckedNodes() - : [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)] - if (nodes[0].level != 4) { - return - } - // console.log(this.leaseApplyDetails) - // console.log(nodes[0].data.id) - for (let i = 0; i < this.leaseApplyDetails.length; i++) { - if (this.leaseApplyDetails[i].typeId == nodes[0].data.id) { - this.leaseApplyDetails.splice(i, 1) - break + const deviceTypeList = + this.$refs.deviceTypeCascader.getCheckedNodes() + + // if (val.length > 0) { + // for (let i in val) { + // console.log(val[i], '----+++') + // } + // } + let tempList = [] + if (val.length > 0) { + const items = val.map((e) => { + return e[3] + }) + for (let i in items) { + for (let z in deviceTypeList) { + if (deviceTypeList[z].data.id === items[i]) { + let { num, companyId, id, unitName } = + deviceTypeList[z].data + tempList.push({ + createBy: this.user.name, + typeId: id, + num, + companyId, + unitCn: unitName, + typeCn: deviceTypeList[z].pathLabels[2], + guigeCn: deviceTypeList[z].pathLabels[3], + }) + break + } + } } } - this.leaseApplyDetails.push(this.handelTableItemData(nodes[0])) - this.deviceType = {} + + this.leaseApplyDetails = [...new Set(tempList)] + + // const templateList = deviceTypeList.map((e) => { + // let { num, companyId, id, unitName } = e.data + // return { + // createBy: this.user.name, + // num, + // companyId, + // typeId: id, + // unitCn: unitName, + // typeCn: e.pathLabels[2], + // guigeCn: e.pathLabels[3], + // } + // }) + // this.leaseApplyDetails = [...new Set(templateList)] + // console.log(templateList, '----') + + // let nodes = null + // nodes = + // this.$refs.deviceTypeCascader.getCheckedNodes().length > 0 + // ? this.$refs.deviceTypeCascader.getCheckedNodes() + // : [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)] + // if (nodes[0].level != 4) { + // return + // } + // // console.log(this.leaseApplyDetails) + // // console.log(nodes[0].data.id) + // for (let i = 0; i < this.leaseApplyDetails.length; i++) { + // if (this.leaseApplyDetails[i].typeId == nodes[0].data.id) { + // this.leaseApplyDetails.splice(i, 1) + // break + // } + // } + // this.leaseApplyDetails.push(this.handelTableItemData(nodes[0])) + // this.deviceType = {} }, //// 将数据处理成 表格中需要的数据 handelTableItemData(node) { @@ -912,3 +1006,21 @@ export default { }, } + + diff --git a/src/views/claimAndreturn/return/apply/component/addReturn1.vue b/src/views/claimAndreturn/return/apply/component/addReturn1.vue index 07ecd98..cd93930 100644 --- a/src/views/claimAndreturn/return/apply/component/addReturn1.vue +++ b/src/views/claimAndreturn/return/apply/component/addReturn1.vue @@ -57,14 +57,18 @@ @@ -159,18 +163,21 @@ label="机具名称" prop="typeName" min-width="200" + align="center" :show-overflow-tooltip="true" /> { + this.deviceTypeTree = res.data + + // console.log(this.deviceTypeTree, this.leaseApplyDetails, '6666') + + let selectList = [] + this.leaseApplyDetails.forEach((e) => { + selectList.push( + this.getParentsById(this.deviceTypeTree, e.typeId), + ) + }) + this.$nextTick(() => { + this.deviceType = selectList + this.propsKey++ + }) + }) + }, + getParentsById(list, id) { + for (let i in list) { + if (list[i].typeId == id) { + //查询到就返回该数组对象的value + return [list[i].typeId] + } + if (list[i].children) { + let node = this.getParentsById(list[i].children, id) + if (node !== undefined) { + //查询到把父节把父节点加到数组前面 + node.unshift(list[i].typeId) + return node + } + } + } }, // 获取 协议id async GetAgreementInfoById() { @@ -587,7 +626,7 @@ export default { }, //生成回显数据 handelEchoData(item) { - console.log('item======', item) + // console.log('item======', item) const template = JSON.parse( JSON.stringify(this.leaseApplyDetailsItem), ) @@ -693,7 +732,7 @@ export default { }, //是否可用勾选框 selectable(row) { - console.log(row) + // console.log(row) if (row.num != 0) { return true } else { @@ -844,6 +883,12 @@ export default { /** 删除按钮操作 */ handleDelete(row) { + this.deviceType.forEach((e, index) => { + if (e[3] === row.typeId) { + this.deviceType.splice(index, 1) + this.propsKey++ + } + }) this.leaseApplyDetails.splice(row.index, 1) }, /** 导出按钮操作 */ @@ -868,38 +913,75 @@ export default { /////// 设备类型树 切换 async deviceTypeChange(val) { - let nodes = null - console.log( - 'vall1211221122', - this.$refs.deviceTypeCascader.getCheckedNodes().length, - this.$refs.deviceTypeCascader.getCheckedNodes(), - [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)], - ) - nodes = - this.$refs.deviceTypeCascader.getCheckedNodes().length > 0 - ? this.$refs.deviceTypeCascader.getCheckedNodes() - : [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)] - console.log('nodes', nodes) - // const res = await getUseNumByTypeId({ typeId: nodes[0].data.typeId }) - nodes[0].data.useNum = nodes[0].data.num - if (nodes[0].level != 4) { - return - } - if (nodes[0].data.useNum < 1) { - this.$modal.msgError('所选机具类型当前无在用!') - return - } - for (let i = 0; i < this.leaseApplyDetails.length; i++) { - if (this.leaseApplyDetails[i].typeId == nodes[0].data.typeId) { - this.leaseApplyDetails.splice(i, 1) - break - } - } - this.leaseApplyDetails.push(this.handelTableItemData(nodes[0])) + // let nodes = null + // console.log( + // 'vall1211221122', + // this.$refs.deviceTypeCascader.getCheckedNodes().length, + // this.$refs.deviceTypeCascader.getCheckedNodes(), + // [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)], + // ) + // nodes = + // this.$refs.deviceTypeCascader.getCheckedNodes().length > 0 + // ? this.$refs.deviceTypeCascader.getCheckedNodes() + // : [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)] + // console.log('nodes', nodes) + // // const res = await getUseNumByTypeId({ typeId: nodes[0].data.typeId }) + // nodes[0].data.useNum = nodes[0].data.num + // if (nodes[0].level != 4) { + // return + // } + // if (nodes[0].data.useNum < 1) { + // this.$modal.msgError('所选机具类型当前无在用!') + // return + // } + // for (let i = 0; i < this.leaseApplyDetails.length; i++) { + // if (this.leaseApplyDetails[i].typeId == nodes[0].data.typeId) { + // this.leaseApplyDetails.splice(i, 1) + // break + // } + // } + // this.leaseApplyDetails.push(this.handelTableItemData(nodes[0])) // this.$refs.cascader.$refs.panel.clearCheckedNodes() // // 设置为空可以让节点不高亮显示 // this.$refs.cascader.$refs.panel.activePath = [] - this.deviceType = {} + // this.deviceType = {} + + const deviceTypeList = + this.$refs.deviceTypeCascader.getCheckedNodes() + + // if (val.length > 0) { + // for (let i in val) { + // console.log(val[i], '----+++') + // } + // } + let tempList = [] + if (val.length > 0) { + const items = val.map((e) => { + return e[3] + }) + for (let i in items) { + for (let z in deviceTypeList) { + if (deviceTypeList[z].data.typeId === items[i]) { + let { num, companyId, typeId, unitNames } = + deviceTypeList[z].data + tempList.push({ + createBy: this.createBy, + typeId, + preNum: num, + num, + companyId, + unitNames, + useNum: num, + typeName: deviceTypeList[z].pathLabels[2], + typeCode: deviceTypeList[z].pathLabels[3], + }) + break + } + } + } + } + + this.leaseApplyDetails = [...new Set(tempList)] }, //// 将数据处理成 表格中需要的数据 handelTableItemData(node) { @@ -921,3 +1003,15 @@ export default { }, } + + diff --git a/src/views/claimAndreturn/return/receive/component/handlePage.vue b/src/views/claimAndreturn/return/receive/component/handlePage.vue index a6bacb1..e6b82dc 100644 --- a/src/views/claimAndreturn/return/receive/component/handlePage.vue +++ b/src/views/claimAndreturn/return/receive/component/handlePage.vue @@ -186,6 +186,12 @@ + - + /> --> + - + - + - + - + +