|
|
@@ -43,7 +43,8 @@ Page({
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- const isEditing = workDetail.status == '进行中' && detail.status != '1';
|
|
|
+ //工单状态为进行中可以编辑,不管工序是进行中还是已完成
|
|
|
+ const isEditing = workDetail.status == '进行中' ;
|
|
|
const workpresetjson = detail.workpresetjson || {};
|
|
|
const attinfos = detail.attinfos || [];
|
|
|
// 按usetype分组
|
|
|
@@ -90,7 +91,7 @@ Page({
|
|
|
|
|
|
// 页面销毁时刷新父页面
|
|
|
onUnload() {
|
|
|
- if (this.data.detail.status == '2') {
|
|
|
+ if (this.data.detail.status != '0') {
|
|
|
const pages = getCurrentPages();
|
|
|
const detailPage = pages.find(v => v.__route__ == 'bgj/workOrder/detail');
|
|
|
if (detailPage && detailPage.getDetail) detailPage.getDetail();
|
|
|
@@ -450,12 +451,21 @@ Page({
|
|
|
if (this.data.saving) return;
|
|
|
this.setData({ saving: true });
|
|
|
|
|
|
+ // 校验必填项是否有值,决定工序状态
|
|
|
+ const hasRequired = !this.validateRequired();
|
|
|
+ const isconfirm = hasRequired ? 1 : 0;
|
|
|
+
|
|
|
_Http.basic({
|
|
|
id: 2026052615154602,
|
|
|
- content: this.buildContent(0),
|
|
|
+ content: this.buildContent(isconfirm),
|
|
|
}).then(res => {
|
|
|
- if (res.code == 1 && this.data.detail.status == '0') {
|
|
|
- this.setData({ 'detail.status': '2' });
|
|
|
+ if (res.code == 1) {
|
|
|
+ const newStatus = hasRequired ? '1' : '2';
|
|
|
+ if (this.data.detail.status != newStatus) {
|
|
|
+ this.setData({
|
|
|
+ 'detail.status': newStatus,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
this.setData({ saving: false });
|
|
|
}).catch(() => {
|
|
|
@@ -468,15 +478,22 @@ Page({
|
|
|
if (this.data.saving) return;
|
|
|
this.setData({ saving: true });
|
|
|
|
|
|
+ // 校验必填项是否有值,决定工序状态
|
|
|
+ const hasRequired = !this.validateRequired();
|
|
|
+ const isconfirm = hasRequired ? 1 : 0;
|
|
|
+
|
|
|
_Http.basic({
|
|
|
id: 2026052615154602,
|
|
|
- content: this.buildContent(0),
|
|
|
+ content: this.buildContent(isconfirm),
|
|
|
}).then(res => {
|
|
|
- if (res.code == 1 && this.data.detail.status == '0') {
|
|
|
- this.setData({ 'detail.status': '2' });
|
|
|
+ if (res.code == 1) {
|
|
|
+ const newStatus = hasRequired ? '1' : '2';
|
|
|
+ this.setData({
|
|
|
+ 'detail.status': newStatus,
|
|
|
+ });
|
|
|
+ wx.showToast({ title: '已保存', icon: 'success' });
|
|
|
}
|
|
|
this.setData({ saving: false });
|
|
|
- wx.showToast({ title: '已保存', icon: 'success' });
|
|
|
}).catch(() => {
|
|
|
this.setData({ saving: false });
|
|
|
wx.showToast({ title: '保存失败', icon: 'none' });
|
|
|
@@ -526,53 +543,4 @@ Page({
|
|
|
return '';
|
|
|
},
|
|
|
|
|
|
- save() {
|
|
|
- if (this.data.loading) return;
|
|
|
-
|
|
|
- const msg = this.validateRequired();
|
|
|
- if (msg) {
|
|
|
- wx.showToast({ title: msg, icon: 'none', duration: 2000 });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Dialog.confirm({
|
|
|
- title: '确认完成',
|
|
|
- message: '确认完成后将不可再修改此工序,请确认信息无误后再提交。',
|
|
|
- confirmButtonText: '确认提交',
|
|
|
- cancelButtonText: '再检查下',
|
|
|
- zIndex: 9999,
|
|
|
- confirmButtonColor: '#3874F6'
|
|
|
- }).then(() => {
|
|
|
- this.doConfirmSave();
|
|
|
- }).catch(() => {});
|
|
|
- },
|
|
|
-
|
|
|
- async doConfirmSave() {
|
|
|
- this.setData({ loading: true });
|
|
|
-
|
|
|
- try {
|
|
|
- const confirmRes = await _Http.basic({
|
|
|
- id: 2026052615154602,
|
|
|
- content: this.buildContent(1),
|
|
|
- });
|
|
|
-
|
|
|
- if (confirmRes.code != 1) {
|
|
|
- this.setData({ loading: false });
|
|
|
- Dialog.alert({
|
|
|
- title: '完成工单失败',
|
|
|
- message: confirmRes.msg,
|
|
|
- zIndex: 9999
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- this.setData({ loading: false });
|
|
|
- // 设置标记,让详情页显示完成成功提示
|
|
|
- getApp().globalData._nodeCompleteSuccess = true;
|
|
|
- wx.navigateBack();
|
|
|
- } catch (e) {
|
|
|
- this.setData({ loading: false });
|
|
|
- wx.showToast({ title: '保存失败', icon: 'none' });
|
|
|
- }
|
|
|
- },
|
|
|
});
|