巡检点编辑

This commit is contained in:
jiayu 2024-07-23 18:05:18 +08:00
parent 056f955e5c
commit ba745a36d2
3 changed files with 109 additions and 68 deletions

View File

@ -78,9 +78,9 @@
</view>
<view class="c_body">
<input class="c_input" v-model="item.value" :placeholder="`请输入${item.title}`" />
<radio-group>
<radio style="margin-right: 12rpx;" value="1" :checked="item.isRequired">必填</radio>
<radio value="2" :checked="!item.isRequired">非必填</radio>
<radio-group @change="((e) => handleChangeRadio(e.detail.value, item))">
<radio style="margin-right: 12rpx;" value="1" :checked="item.isRequired == '1'">必填</radio>
<radio value="2" :checked="item.isRequired == '2'">非必填</radio>
</radio-group>
</view>
</view>
@ -131,7 +131,12 @@
longitude: "", //
addr: "", //
},
dyFormData: []
dyFormData: [{
title: "表单标题",
name: "",
isRequired: "1",
value: "",
}]
}
},
async onLoad(option) {
@ -148,22 +153,16 @@
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
this.editId = ""
await this.getPointAreaFn();
//
if(option.id) {
this.editId = option.id;
// await this.getData()
await this.getPointAreaFn();
await this.getData()
} else {
await this.getPointAreaFn();
this.mapGetLocation();
}
console.info(option, '-------')
// this.taskId = option.taskId
// this.itemId = option.itemId
// this.form.taskId = option.taskId
// this.form.itemId = option.itemId
// if(option.engineeringId) this.engineeringId = option.engineeringId
// if(option.type) this.type = Number(option.type)
},
mounted() {
var that = this
@ -175,45 +174,74 @@
}
})
console.log('this.mobileTopHeight',this.mobileTopHeight)
this.dyFormData.splice(0);
this.dyFormData.push({
title: "表单标题",
name: "",
isRequired: "1",
value: "",
});
},
methods: {
//
getData() {
this.sendRequest({
url: 'xmgl/checkingPoint/queryById',
method: 'get',
data: {
id: this.editId
},
success: (res) => {
if(res.code === 200) {
this.form = res.result
console.info(this.pointAreaList.find(item => item.id === this.form.qualityRegionId))
new Promise((resolve, reject) => {
console.info("getData", new Date().getTime())
this.sendRequest({
url: 'xmgl/checkingPoint/queryById',
method: 'get',
data: {
id: this.editId
},
success: (res) => {
if(res.code === 200) {
this.form = res.result
//
const obj = this.pointAreaList.find(item => item.id === this.form.qualityRegionId)
this.areaData = obj || {}
//
this.enterpriseList = this.areaData.enterpriseInfos || [];
const eObj = this.enterpriseList.filter(item => this.form.enterpriseId.includes(item.id))
this.enterpriseName = eObj.map(item => item.enterpriseName).join(',')
//
this.chargerList = this.areaData.systemUsers.filter((item) => {
return this.form.enterpriseId.includes(item.enterpriseId);
}) || [];
this.inspectUserName = this.chargerList.filter(item => this.form.inspectUserIds.includes(item.userId)).map(item => item.realName).join(',')
let tempArr = JSON.parse(this.form.template) || []
tempArr.forEach(item => item.isRequired = item.isRequired ? "1" : "2")
//
this.dyFormData = tempArr
console.info(eObj, 'eObj', this.dyFormData, tempArr)
resolve(res)
}
console.log(res, 'xiangqing');
},
fail: (err) => {
reject(err)
}
console.log(res, 'xiangqing');
}
})
})
},
//
getPointAreaFn() {
let requestData = {
projectSn: this.projectSn,
};
this.sendRequest({
url: 'xmgl/qualityRegion/notTreeList',
method: 'post',
data: requestData,
success: (res) => {
console.log(res);
this.pointAreaList = res.result;
}
new Promise((resolve, reject) => {
console.info("getPointAreaFn", new Date().getTime())
let requestData = {
projectSn: this.projectSn,
};
this.sendRequest({
url: 'xmgl/qualityRegion/notTreeList',
method: 'post',
data: requestData,
success: (res) => {
console.log(res);
this.pointAreaList = res.result;
console.info("getPointAreaFn处理结束", new Date().getTime())
resolve(res)
},
fail: (err) => {
reject(err)
}
})
})
},
//
@ -232,7 +260,6 @@
},
//
handleChangeEnterprise(e,values,labels) {
console.info(e, 'eee', this.form.enterpriseId, values, labels)
this.form.enterpriseId = values.join(',');
this.$nextTick(() => {
if(this.form.enterpriseId) {
@ -252,15 +279,16 @@
},
//
handleChangeCharger(e,values,labels) {
console.info(e, 'eeeee')
this.form.inspectUserIds = values.join(',');
console.info(this.form.inspectUserIds, "inspectUserIds")
},
//
handleChangeStandArea(e) {
console.info(e,'eee')
this.form.standArea = this.standOptions[e.detail.value];
},
handleChangeRadio(e, item) {
item.isRequired = e;
},
handleJumpMap() {
uni.navigateTo({
url: `/pages/projectEnd/InspectionRoute/mapLocatoin/mapLocatoin?standArea=${this.form.standArea}&latitude=${this.form.latitude}&longitude=${this.form.longitude}&addr=${this.form.addr}`
@ -308,17 +336,28 @@
params.createUserId = this.userInfo.userId;
params.createUserName = this.userInfo.account;
let newDyForm = this.deepClone(this.dyFormData);
params.template = JSON.stringify(newDyForm.forEach(item => item.isRequired = item.isRequired == "1" ? true : false));
newDyForm.forEach(item => {
item.isRequired = item.isRequired == "1" ? true : false
})
params.template = JSON.stringify(newDyForm);
let apiUrl = 'xmgl/checkingPoint/add';
let msg = "添加成功"
//
if(this.editId) {
apiUrl = "xmgl/checkingPoint/edit"
msg = "保存成功";
}
this.sendRequest({
url: 'xmgl/checkingPoint/add',
url: apiUrl,
method: 'post',
data: params,
success: res => {
console.info(res,'res')
if (res.code == 200) {
uni.showToast({
title: '保存成功'
title: msg
})
setTimeout(() => {
uni.redirectTo({
@ -399,21 +438,6 @@
return false
}
return true
// checkingPointName: "",
// position: "",
// qualityRegionId: "", // ID
// enterpriseId: "", //
// inspectUserIds: "", //
// noticeUserIds: "", //
// startTime: "",
// endTime: "",
// frequencyType: 1,
// frequencyNum: 1,
// minInspectTime: undefined,
// standArea: 100, //
// latitude: "", //
// longitude: "", //
// addr: "", //
}
}
}

View File

@ -54,7 +54,7 @@
</view>
<view class="btn_wrap">
<view class="common_btn primary" @click="handleEdit(item)"><image class="b_ic" src="@/static/icon/edit.svg"></image></view>
<view class="common_btn danger"><image class="b_ic" src="@/static/icon/delete.svg"></image></view>
<view class="common_btn danger" @click="handleDel(item)"><image class="b_ic" src="@/static/icon/delete.svg"></image></view>
</view>
</view>
</view>
@ -208,6 +208,23 @@
url: `/pages/projectEnd/InspectionRoute/editInspectionPoint?id=${data.id}`
})
},
handleDel(data) {
this.sendRequest({
url: 'xmgl/checkingPoint/delete',
method: 'get',
data:{id: data.id},
success: res => {
console.info(res,'res')
if (res.code == 200) {
uni.showToast({
title: "删除成功"
})
this.condition.pageNo = 1
this.getListData(true)
}
}
})
},
//
loadData(e) {
// this.condition.search = e.detail.value

File diff suppressed because one or more lines are too long