Commit 073562dd06d020bd7862221a0f10d14d5de82db7

Authored by 王彪总
1 parent c4409bc7

业务线 小程序不用写死,从后端接口获取

api/maintain-manage/maintain-manage.js
... ... @@ -101,7 +101,9 @@ export const maintainPlanList= (params) => {
101 101 * @returns {Promise}
102 102 */
103 103 export const finishPlan= (params) => {
104   - return post('/app-api/app/garden/maintain-plan-commit/finish',params);
  104 + // 后端 /finish 使用 @RequestParam("planNo"),必须放 query,不能放 JSON body
  105 + const planNo = params && params.planNo != null ? params.planNo : '';
  106 + return post(`/app-api/app/garden/maintain-plan-commit/finish?planNo=${encodeURIComponent(planNo)}`, {});
105 107 };
106 108  
107 109 /**
... ...
pages-sub/daily/maintain-manage/add-record.vue
... ... @@ -934,17 +934,24 @@ export default {
934 934 uni.showLoading({ title: '提交中...' })
935 935 this.submitting = true
936 936  
  937 + // 后端 AppMaintainPlanCommitSaveReqVO:imgHost 是 String(必填),beginImg 才是图片列表
  938 + const submitData = {
  939 + planNo: this.paramsOptins.planNo,
  940 + imgHost: '1',
  941 + beginImg: this.getImgUrlList(this.imagesList),
  942 + commonUserList: [],
  943 + remark: this.inspectForm.remark.trim(),
  944 + }
  945 +
  946 + // 只调一次 /create-and-finish:后端会新增一条带完成时间的上报记录并更新完成次数,
  947 + // 若先调 maintainCreate 会多出一条重复记录
937 948 if (!this.commitId) {
938   - const submitData = {
939   - planNo: this.paramsOptins.planNo,
940   - imgHost: this.getImgUrlList(this.imagesList),
941   - commonUserList: [],
942   - remark: this.inspectForm.remark.trim(),
943   - }
944   - const commitRes: any = await maintainCreate(submitData)
  949 + const commitRes: any = await maintainCreateFinish(submitData)
  950 + // 兼容后端返回裸 id 或 {id:...} 两种形态
945 951 this.commitId = commitRes && typeof commitRes === 'object' ? commitRes.id : commitRes
946 952 }
947 953  
  954 + // 动态字段挂到本次完成记录上;重试时 commitId 已缓存,只补写字段
948 955 if (dynamicValues.length > 0 && this.commitId) {
949 956 await workRecordSubmit({
950 957 businessType: this.paramsOptins.businessType,
... ... @@ -957,11 +964,6 @@ export default {
957 964 })
958 965 }
959 966  
960   - // 新增:调用【提交并结束】接口
961   - await maintainCreateFinish({
962   - id: this.commitId
963   - })
964   -
965 967 uni.hideLoading()
966 968 uni.showToast({ title: '提交并结束任务成功', icon: 'success', duration: 1000 })
967 969 setTimeout(() => {
... ...