qa-prevention-xgf-app/hiddenManageSubPackages/pages/hidden_acceptance/acceptance.vue

196 lines
4.6 KiB
Vue

<template>
<view class="container">
<view class="card">
<!-- 隐患详情查看 -->
<app-hidden-view
:hidden-id="hiddenId"
@throw-basic-info="info = $event.pd"
/>
<!-- 隐患验收 -->
<view v-if="isSubmit === '0'" class="card">
<u-form
ref="formRef"
label-position="left"
:model="form"
:rules="rules"
label-width="auto"
>
<u-divider text-position="left" text="隐患验收"></u-divider>
<u-form-item label="是否合格" prop="ISQUALIFIED" required>
<u-radio-group v-model="form.ISQUALIFIED" direction="horizontal">
<u-radio name="1" label="是" />
<u-radio name="0" label="否" />
</u-radio-group>
</u-form-item>
<u-line />
<block v-if="form.ISQUALIFIED === '1'">
<u-form-item
label="验收描述"
prop="CHECKDESCR"
label-position="top"
required
>
<u-textarea
v-model="form.CHECKDESCR"
placeholder="请输入验收描述"
border="none"
auto-height
/>
</u-form-item>
<u-line />
<app-time
:model-value="form.CHECK_TIME"
label="验收日期"
prop="CHECK_TIME"
mode="date"
@fn-confirm-emit="fnConfirmEmit"
/>
<app-upload
:model-value="form.acceptanceFile"
label="验收图片"
prop="acceptanceFile"
/>
</block>
<view class="mt-10">
<u-button
type="primary"
shape="circle"
text="提交"
:throttle-time="1000"
@click="fnSubmit"
/>
</view>
</u-form>
</view>
</view>
</view>
</template>
<script>
import AppHiddenView from "@/components/hiddenView/index.vue";
import AppTime from "@/components/time/index.vue";
import AppUpload from "@/components/upload/index.vue";
import {
getHiddenAcceptanceCurrentPersonnelIsCheck,
setHiddenAcceptanceSubmit,
} from "../../api";
import dayjs from 'dayjs';
import useFormValidate from "@/utils/useFormValidate";
export default {
components: { AppHiddenView, AppTime, AppUpload },
data() {
return {
store: this.$store,
hiddenId: "",
isSubmit: "",
info: {},
form: {
ISQUALIFIED: "1",
CHECKDESCR: "",
CHECK_TIME: "",
acceptanceFile: [],
},
// 表单校验规则
rules: {
ISQUALIFIED: {
type: "string",
required: true,
message: "请选择是否合格",
trigger: ["blur", "change"],
},
CHECKDESCR: {
type: "string",
required: true,
message: "请输入验收描述",
trigger: ["blur", "change"],
},
CHECK_TIME: {
type: "string",
required: true,
message: "请选择验收日期",
trigger: ["blur", "change"],
},
acceptanceFile: {
type: "array",
required: true,
message: "请上传验收图片",
trigger: ["blur", "change"],
},
},
};
},
onLoad(query) {
this.hiddenId = query.HIDDEN_ID;
this.fnGetCurrentPersonnelIsCheck();
},
methods: {
async fnGetCurrentPersonnelIsCheck() {
// const { isTrue } = await getHiddenAcceptanceCurrentPersonnelIsCheck({
// HIDDEN_ID: this.hiddenId,
// CHECKOR: this.store.state.userInfo.USER_ID,
// });
// console.log('isTrue :>> ', isTrue);
// this.isSubmit = isTrue;
this.isSubmit = "success"; // todo目前写死,等待后端接口返回真实数据
},
async fnUploadFile(filePath, FOREIGN_KEY, TYPE) {
await setUploadFile({
filePath,
formData: {
FOREIGN_KEY,
TYPE,
},
});
},
async fnSubmit() {
await useFormValidate(this.$refs.formRef);
console.log('this.form :>> ', this.form);
// const { check } = await setHiddenAcceptanceSubmit({
// HIDDEN_ID: this.hiddenId,
// CHECKOR: this.store.state.userInfo.USER_ID,
// USERNAME: this.store.state.userInfo.NAME,
// INSPECTION_ID: this.info.FOREIGN_ID,
// ...this.form,
// });
// for (let i = 0; i < this.form.acceptanceFile.length; i++) {
// await this.fnUploadFile(
// this.form.acceptanceFile[i].url,
// check.HIDDENCHECK_ID,
// 5
// );
// }
uni.showToast({
icon: "none",
title: "提交成功",
});
setTimeout(() => {
uni.navigateBack();
}, 1000);
},
fnConfirmEmit({ mode, value }) {
if (mode === "datetime") {
this.form = {
...this.form,
CHECK_TIME: dayjs(value).format("YYYY-MM-DD HH:mm"),
};
} else if (mode === "date") {
this.form = {
...this.form,
CHECK_TIME: dayjs(value).format("YYYY-MM-DD"),
};
} else if (mode === "year-month") {
this.form = {
...this.form,
CHECK_TIME: dayjs(value).format("YYYY-MM"),
};
}
}
},
};
</script>