You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udiwms-vue-frame/src/views/dev/js/deviceRepairApplyMy.js

286 lines
7.7 KiB
JavaScript

import {getLoading, copyProperties} from "@/utils"
import {
deviceRepairApplyHallPage,
deviceRepairApplyConfirmByUserPage,
confirmDeviceRepairApply
} from "@/api/dev/deviceRepairApplyApi";
import {deviceRepairApplyDetailStatus, deviceRepairApplyStatus} from "@/utils/enum";
import {deviceRepairApplyDetailDiagnosis, deviceRepairApplyDetailPage} from "@/api/dev/deviceRepairApplyDetailApi";
import {deviceRepairInfo} from "@/api/dev/deviceRepairApi";
import {filterListByDeptCode} from "@/api/system/deptUser";
let query = {
page: 1,
limit: 10,
applyId: null,
status: null,
applyDeptCode: null,
}
let detailQuery = {
page: 1,
limit: 10,
applyId: null,
}
let diagnosisData = {
applyId: null,
deviceCode: null,
repairFlag: true,
innerFlag: true,
repairDeptCode: null,
repairUserName: '',
repairUserPhone: '',
diagnosisInfo: '',
}
export default {
name: "deviceRepairApply",
computed: {
deviceRepairApplyDetailStatus() {
return deviceRepairApplyDetailStatus
},
deviceRepairApplyStatus() {
return deviceRepairApplyStatus
}
},
data() {
return {
tabActive: 2,
showSearch: true,
loading: false,
total: 0,
list: [],
userlist: [],
query: {...query},
user: null,
chooseDeviceFlag: false,
//========detail===============================
clickRow: null,
detailQuery: _.cloneDeep(detailQuery),
detailLoading: false,
detailList: [],
detailTotal: 0,
//========detail--end===============================
repairId: null,
//========detailDialog===============================
detailFlag: false,
detailData: null,
diagnosisData: _.cloneDeep(diagnosisData),
detailRules: {
repairFlag: [{required: true, message: "请选择是否维修", trigger: ["change", "blur"]}],
innerFlag: [{
required: true,
validator: this.innerFlagValid,
message: "请选择维修方式",
trigger: ["change", "blur"]
}],
repairDeptCode: [{
required: true,
validator: this.repairDeptCodeValid,
message: "维修部门不能为空",
trigger: ["change", "blur"]
}],
repairUserName: [{
required: true,
validator: this.repairUserNameValid,
message: "维修人姓名不能为空",
trigger: ["change", "blur"]
}],
repairUserPhone: [{
required: true,
validator: this.repairUserPhoneValid,
message: "维修人电话不能为空",
trigger: ["change", "blur"]
}],
diagnosisInfo: [{required: true, message: "诊断信息不能为空", trigger: ["change", "blur"]}],
},
//========detailDialog--end===============================
}
}
,
watch: {
'diagnosisData.repairDeptCode': {
handler (newV, oldV) {
this.getUerList()
},
// deep: true,
// immediate: true,
}
},
created() {
this.user = this.$store.getters.user
this.getList()
},
methods: {
repairInfo(row) {
this.repairId = row.repairId
},
commitFunc() {
this.$refs.saveForm.validate(b => {
if (!b) {
return
}
deviceRepairApplyDetailDiagnosis(this.diagnosisData).then(res => {
if (res.code != 20000) {
this.$message.error(res.message)
return
}
this.$message.success(res.message)
this.detailFlag = false
this.getList()
})
})
},
repairUserPhoneValid(rule, value, callback) {
if (this.diagnosisData?.repairFlag) {
if (!this.diagnosisData.repairUserPhone) {
callback(new Error("维修人电话不能为空"))
}
}
callback()
},
repairUserNameValid(rule, value, callback) {
if (this.diagnosisData?.repairFlag) {
if (!this.diagnosisData.repairUserName) {
callback(new Error("维修人姓名不能为空"))
}
}
callback()
},
repairDeptCodeValid(rule, value, callback) {
if (this.diagnosisData?.repairFlag) {
if (!this.diagnosisData.repairDeptCode) {
callback(new Error("维修部门不能为空"))
}
}
callback()
},
innerFlagValid(rule, value, callback) {
if (this.diagnosisData?.repairFlag) {
if (this.diagnosisData.innerFlag == null) {
callback(new Error("请选择维修方式"))
}
}
callback()
},
openDiagnosisDialog(row) {
this.detailFlag = true
this.detailData = _.cloneDeep(row)
this.diagnosisData = _.cloneDeep({...diagnosisData, applyId: row.applyId, deviceCode: row.deviceCode})
},
confirm(row) {
this.$prompt("请输入受理人电话", "提示", {
closeOnClickModal: false,
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: String,
inputPlaceholder: '请输入受理人电话',
}).then(({value}) => {
let data = {
applyId: row.id,
confirmUserPhone: value
}
confirmDeviceRepairApply(data).then(res => {
if (res.code != 20000) {
this.$message.error(res.message)
return
}
this.$message.success(res.message)
this.getList()
})
})
},
tabClick(v, ov) {
if (v == ov) {
return
}
this.tabActive = v
this.query = _.cloneDeep(query)
this.getList()
},
rowClick(row) {
this.clickRow = row
this.detailQuery = _.cloneDeep({...detailQuery, applyId: row.id})
this.getDetailList()
},
getDetailList() {
this.detailLoading = true
deviceRepairApplyDetailPage(this.detailQuery).then(res => {
this.detailLoading = false
if (res.code != 20000) {
this.$message.error(res.message)
return
}
this.detailList = res.data.list || []
this.detailTotal = res.data.total || 0
}).catch(e => {
this.detailLoading = false
})
},
search() {
this.query.page = 1
this.getList()
},
onReset() {
this.query = {...query}
this.getList()
},
getList() {
this.loading = true
this.clickRow = null
this.detailList = []
this.detailTotal = 0
if (this.tabActive == 1) {
deviceRepairApplyHallPage(this.query).then(res => {
this.loading = false
if (res.code != 20000) {
this.$message.error(res.message)
return
}
this.list = res.data.list || []
this.total = res.data.total || 0
}).catch(e => {
this.loading = false
this.list = res.data.list || []
this.total = res.data.total || 0
})
} else {
deviceRepairApplyConfirmByUserPage(this.query).then(res => {
this.loading = false
if (res.code != 20000) {
this.$message.error(res.message)
return
}
this.list = res.data.list || []
this.total = res.data.total || 0
}).catch(e => {
this.loading = false
this.list = res.data.list || []
this.total = res.data.total || 0
})
}
},
getUerList() {
if (this.diagnosisData.repairDeptCode != null){
let userQuery = {
deptCode: this.diagnosisData.repairDeptCode,
}
filterListByDeptCode(userQuery).then((response) => {
// this.loading = false;
this.userlist = response.data.list || [];
// this.userTotal = response.data.total;
})
.catch(() => {
// this.loading = false;
this.userlist = [];
// this.userTotal = 0;
});
}
}
}
}