| | |
| | | <template> |
| | | <el-dialog :title="titleMap[mode]" v-model="visible" :width="570" destroy-on-close @closed="$emit('closed')"> |
| | | <div v-if="isShow">历史反馈</div> |
| | | <el-row v-if="isShow" class="history-feedback"> |
| | | <el-col :span="24"><span>开始反馈时间</span><span>{{latestData.feedbackTime}}</span></el-col> |
| | | <el-col :span="24"><span>状态</span><span>{{latestData.wcsDesc}}</span></el-col> |
| | | <el-col :span="24"><span>描述</span><span>{{latestData.feedbackDesc}}</span></el-col> |
| | | <el-col :span="24"><span>状态持续时间</span><span>{{latestData.diffTime}}</span></el-col> |
| | | </el-row> |
| | | <div v-if="isShow" class="modal-title">最新反馈</div> |
| | | <el-form :model="addDictForm" :rules="addDictRules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :span="24"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="状态" prop="wcs"> |
| | | <el-select v-model="addDictForm.wcs" style="width: 100%"> |
| | | <el-option v-for="item in feedBackStatusList" :key="item.code" :label="item.name" :value="item.code"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> --> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="描述"> |
| | | <el-input v-model="addDictForm.description" placeholder="描述" clearable></el-input> |
| | |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="visible=false" >取 消</el-button> |
| | | <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="dictSubmit()">保 存</el-button> |
| | | <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="dictSubmit">提交反馈</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | |
| | | <script> |
| | | export default { |
| | | emits: ['success', 'closed'], |
| | | props: ['workstationId'], |
| | | data() { |
| | | return { |
| | | feedBackStatusList: [], |
| | | latestData: { |
| | | latestData: "", |
| | | wcsDesc: "", |
| | | feedbackDesc: "", |
| | | diffTime: "" |
| | | }, |
| | | isShow: false, |
| | | value1: true, |
| | | mode: "add", |
| | | titleMap: { |
| | | add: '状态反馈', |
| | | edit: '修改', |
| | | show: '查看' |
| | | edit: '状态反馈', |
| | | show: '状态反馈' |
| | | }, |
| | | visible: false, |
| | | isSaveing: false, |
| | | //表单数据 |
| | | addDictForm: { |
| | | description: "", |
| | | date: "", |
| | | date: [], |
| | | endTime: "", |
| | | startTime: "", |
| | | wcs: "" |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | sumTime(startTime,endTime) { |
| | | // 将字符串转换为Date对象 |
| | | var startDate = new Date(startTime); |
| | | var endDate = new Date(endTime); |
| | | |
| | | // 计算时间差(毫秒) |
| | | var timeDiff = endDate - startDate; |
| | | |
| | | // 将时间差转换为天数、小时数、分钟数和秒数 |
| | | var diffDays = Math.floor(timeDiff / (1000 * 60 * 60 * 24)); // 天 |
| | | timeDiff %= 1000 * 60 * 60 * 24; // 剩余毫秒数 |
| | | var diffHours = Math.floor(timeDiff / (1000 * 60 * 60)); // 小时 |
| | | timeDiff %= 1000 * 60 * 60; // 剩余毫秒数 |
| | | var diffMinutes = Math.floor(timeDiff / (1000 * 60)); // 分钟 |
| | | timeDiff %= 1000 * 60; // 剩余毫秒数 |
| | | var diffSeconds = Math.floor(timeDiff / 1000); // 秒 |
| | | var d = diffDays == 0?"":diffDays + "天"; |
| | | return d + diffHours + "小时 " + diffMinutes + "分钟 " + diffSeconds + "秒" |
| | | }, |
| | | dateChange(val) { |
| | | this.addDictForm.startTime = val[0]; |
| | | this.addDictForm.endTime = val[1]; |
| | |
| | | this.visible = true; |
| | | return this |
| | | }, |
| | | getfeedBackStatusList() { |
| | | this.$HTTP.get("/api/blade-cps/global_wcs/wcs-achievements").then(res=> { |
| | | if(res.code == 200) { |
| | | res.data.forEach(item=> { |
| | | if(item.type == "4") { |
| | | this.feedBackStatusList.push(item); |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //表单提交方法 |
| | | dictSubmit(){ |
| | | var obj = Object.assign({},this.addDictForm); |
| | | obj.workstationIds = [this.workstationId] |
| | | obj.workstationIds = [this.workstationId]; |
| | | var that = this; |
| | | this.$refs.dialogForm.validate(async (valid) => { |
| | | if (valid) { |
| | |
| | | }) |
| | | }, |
| | | //表单注入数据 |
| | | setData(data){ |
| | | //可以和上面一样单个注入,也可以像下面一样直接合并进去 |
| | | //Object.assign(this.addDictForm, data); |
| | | setData(lastLevelId){ |
| | | this.getfeedBackStatusList(); //获取状态list |
| | | this.$HTTP.get(`/api/blade-cps/workstation-wcs-feedback/latest?workstationId=${lastLevelId}`).then(res=> { |
| | | if(res.code == 200) { |
| | | if(res.data == null) { |
| | | this.isShow = false; |
| | | }else { |
| | | res.data.diffTime = this.sumTime(res.data.startTime,res.data.endTime); |
| | | this.latestData = res.data; |
| | | this.isShow = true; |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | <style scoped> |
| | | .history-feedback { |
| | | background: #f5f5f5; |
| | | padding: 12px 0; |
| | | padding-bottom: 24px; |
| | | margin: 16px 0 24px 0; |
| | | } |
| | | .history-feedback .el-col.el-col-24 { |
| | | margin: 24px 0 0px 40px; |
| | | font-size: 14px; |
| | | } |
| | | .history-feedback .el-col.el-col-24 span:nth-child(1) { |
| | | display: inline-block; |
| | | min-width: 100px; |
| | | } |
| | | .modal-title { |
| | | margin-bottom: 20px; |
| | | } |
| | | </style> |