基本功能都已完成
This commit is contained in:
@@ -1,246 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const request_api = require("../../request/api.js");
|
||||
const request_request = require("../../request/request.js");
|
||||
if (!Array) {
|
||||
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
|
||||
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
||||
const _easycom_up_datetime_picker2 = common_vendor.resolveComponent("up-datetime-picker");
|
||||
const _easycom_up_select2 = common_vendor.resolveComponent("up-select");
|
||||
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
|
||||
(_easycom_up_textarea2 + _easycom_up_input2 + _easycom_up_datetime_picker2 + _easycom_up_select2 + _easycom_up_upload2)();
|
||||
}
|
||||
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
|
||||
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
|
||||
const _easycom_up_datetime_picker = () => "../../uni_modules/uview-plus/components/u-datetime-picker/u-datetime-picker.js";
|
||||
const _easycom_up_select = () => "../../uni_modules/uview-plus/components/u-select/u-select.js";
|
||||
const _easycom_up_upload = () => "../../uni_modules/uview-plus/components/u-upload/u-upload.js";
|
||||
if (!Math) {
|
||||
(_easycom_up_textarea + _easycom_up_input + _easycom_up_datetime_picker + _easycom_up_select + _easycom_up_upload)();
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "rectification",
|
||||
setup(__props) {
|
||||
const hazardId = common_vendor.ref("");
|
||||
const assignId = common_vendor.ref("");
|
||||
const formData = common_vendor.reactive({
|
||||
rectifyPlan: "",
|
||||
// 整改方案
|
||||
rectifyResult: "",
|
||||
// 整改完成情况
|
||||
planCost: "",
|
||||
// 投资资金(计划)
|
||||
actualCost: ""
|
||||
// 投资资金(实际)
|
||||
});
|
||||
const show = common_vendor.ref(false);
|
||||
const value1 = common_vendor.ref(Date.now());
|
||||
common_vendor.ref("");
|
||||
const cateId = common_vendor.ref("");
|
||||
const cateList = common_vendor.ref([]);
|
||||
const selectedUserName = common_vendor.ref("");
|
||||
const fetchDeptUsers = async () => {
|
||||
try {
|
||||
const res = await request_api.getDepartmentPersonUsers();
|
||||
if (res.code === 0 && res.data) {
|
||||
const userList = [];
|
||||
res.data.forEach((dept) => {
|
||||
if (dept.users && dept.users.length > 0) {
|
||||
dept.users.forEach((user) => {
|
||||
userList.push({
|
||||
id: String(user.userId),
|
||||
name: `${user.nickName}(${dept.deptName})`
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
cateList.value = userList;
|
||||
console.log("整改人员列表:", cateList.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取部门人员失败:", error);
|
||||
}
|
||||
};
|
||||
fetchDeptUsers();
|
||||
const fileList1 = common_vendor.ref([]);
|
||||
const deletePic = (event) => {
|
||||
fileList1.value.splice(event.index, 1);
|
||||
};
|
||||
const afterRead = async (event) => {
|
||||
let lists = [].concat(event.file);
|
||||
let fileListLen = fileList1.value.length;
|
||||
lists.map((item) => {
|
||||
fileList1.value.push({
|
||||
...item,
|
||||
status: "uploading",
|
||||
message: "上传中"
|
||||
});
|
||||
});
|
||||
for (let i = 0; i < lists.length; i++) {
|
||||
const result = await uploadFilePromise(lists[i].url);
|
||||
let item = fileList1.value[fileListLen];
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: "success",
|
||||
message: "",
|
||||
url: result
|
||||
});
|
||||
fileListLen++;
|
||||
}
|
||||
};
|
||||
const uploadFilePromise = (filePath) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.uploadFile({
|
||||
url: request_request.baseUrl + "/frontend/attachment/upload",
|
||||
filePath,
|
||||
name: "file",
|
||||
header: {
|
||||
"Authorization": request_request.getToken()
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
reject(data.msg || "上传失败");
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("上传失败:", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.rectifyPlan) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入整改方案",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!formData.rectifyResult) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入整改完成情况",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
const attachments = fileList1.value.map((file) => {
|
||||
let url = "";
|
||||
if (typeof file.url === "string") {
|
||||
url = file.url;
|
||||
} else if (file.url && typeof file.url === "object") {
|
||||
url = file.url.url || file.url.path || "";
|
||||
}
|
||||
const fileName = typeof url === "string" && url ? url.split("/").pop() : file.name || "";
|
||||
return {
|
||||
fileName: fileName || "",
|
||||
filePath: url || "",
|
||||
fileType: file.type || "image/png",
|
||||
fileSize: file.size || 0
|
||||
};
|
||||
});
|
||||
const params = {
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value,
|
||||
rectifyPlan: formData.rectifyPlan,
|
||||
rectifyResult: formData.rectifyResult,
|
||||
planCost: Number(formData.planCost) || 0,
|
||||
actualCost: Number(formData.actualCost) || 0,
|
||||
attachments
|
||||
};
|
||||
try {
|
||||
const res = await request_api.submitRectification(params);
|
||||
if (res.code === 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "提交成功",
|
||||
icon: "success"
|
||||
});
|
||||
setTimeout(() => {
|
||||
common_vendor.index.navigateBack();
|
||||
}, 1500);
|
||||
} else {
|
||||
common_vendor.index.showToast({
|
||||
title: res.msg || "提交失败",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("提交整改失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: "您不是整改人员",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
};
|
||||
common_vendor.onLoad((options) => {
|
||||
if (options.hazardId) {
|
||||
hazardId.value = options.hazardId;
|
||||
}
|
||||
if (options.assignId) {
|
||||
assignId.value = options.assignId;
|
||||
}
|
||||
});
|
||||
const selectItem = (item) => {
|
||||
console.log("选择的整改人员:", item);
|
||||
cateId.value = item.id;
|
||||
selectedUserName.value = item.name;
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.o(($event) => formData.rectifyPlan = $event),
|
||||
b: common_vendor.p({
|
||||
placeholder: "请输入内容",
|
||||
modelValue: formData.rectifyPlan
|
||||
}),
|
||||
c: common_vendor.o(($event) => formData.rectifyResult = $event),
|
||||
d: common_vendor.p({
|
||||
placeholder: "请输入内容",
|
||||
modelValue: formData.rectifyResult
|
||||
}),
|
||||
e: common_vendor.o(($event) => formData.planCost = $event),
|
||||
f: common_vendor.p({
|
||||
placeholder: "请输入内容",
|
||||
type: "number",
|
||||
modelValue: formData.planCost
|
||||
}),
|
||||
g: common_vendor.o(($event) => formData.actualCost = $event),
|
||||
h: common_vendor.p({
|
||||
placeholder: "请输入内容",
|
||||
type: "number",
|
||||
modelValue: formData.actualCost
|
||||
}),
|
||||
i: common_vendor.o(($event) => value1.value = $event),
|
||||
j: common_vendor.p({
|
||||
hasInput: true,
|
||||
show: show.value,
|
||||
mode: "date",
|
||||
modelValue: value1.value
|
||||
}),
|
||||
k: selectedUserName.value
|
||||
}, selectedUserName.value ? {
|
||||
l: common_vendor.t(selectedUserName.value)
|
||||
} : {}, {
|
||||
m: common_vendor.o(selectItem),
|
||||
n: common_vendor.o(($event) => cateId.value = $event),
|
||||
o: common_vendor.p({
|
||||
options: cateList.value,
|
||||
current: cateId.value
|
||||
}),
|
||||
p: common_vendor.o(afterRead),
|
||||
q: common_vendor.o(deletePic),
|
||||
r: common_vendor.p({
|
||||
fileList: fileList1.value,
|
||||
name: "1",
|
||||
multiple: true,
|
||||
maxCount: 10
|
||||
}),
|
||||
s: common_vendor.o(handleSubmit)
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f18ba0ce"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
Reference in New Issue
Block a user