123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <template>
- <div class="form" style="padding-bottom: 60px">
- <van-nav-bar
- :title="$t('receive.name')"
- :left-text="$t('common.back')"
- left-arrow
- @click-left="onClickLeft"
- >
- </van-nav-bar>
- <testForm
- v-model="formData.data"
- :formOption="formOption"
- :formConfig="formConfig"
- :rules="rules"
- @onSubmit="onSubmit"
- @otherBtnClick="otherBtnClick"
- ref="formDom"
- >
- <template #productRemark>
- <div style="width: 100%">
- {{ formData.data.productRemark }}
- </div>
- </template>
- <template #fileTwo>
- <div
- style="width: 100%"
- v-if="
- formData.data.fileListTwo && formData.data.fileListTwo.length > 0
- "
- >
- <span
- v-for="item in formData.data.fileListTwo"
- :key="item.id"
- @click="onPreviewFile(item)"
- style="margin-right: 10px; cursor: pointer; color: #409eff"
- >
- {{ item.name }}
- </span>
- </div>
- <div v-else>无</div>
- </template>
- <template #fileThree>
- <div
- style="width: 100%"
- v-if="
- formData.data.fileListThree &&
- formData.data.fileListThree.length > 0
- "
- >
- <span
- v-for="item in formData.data.fileListThree"
- :key="item.id"
- @click="onPreviewFile(item)"
- style="margin-right: 10px; cursor: pointer; color: #409eff"
- >
- {{ item.name }}
- </span>
- </div>
- <div v-else>无</div>
- </template>
- </testForm>
- </div>
- </template>
- <script setup>
- import { ref, reactive, getCurrentInstance, onMounted } from "vue";
- import { showSuccessToast, showFailToast } from "vant";
- import { showConfirmDialog } from "vant";
- import { useRoute } from "vue-router";
- import testForm from "@/components/testForm/index.vue";
- const proxy = getCurrentInstance().proxy;
- const route = useRoute();
- const formDom = ref(null);
- const formData = reactive({
- data: {
- list: [],
- },
- });
- const rules = {
- warehouseName: [
- { required: true, message: proxy.t("receive.warehouseNameCanNotBeEmpty") },
- ],
- productName: [
- { required: true, message: proxy.t("receive.itemNameCanNotBeEmpty") },
- ],
- quantity: [
- {
- required: true,
- message: proxy.t("receive.warehousingQuantityCanNotBeEmpty"),
- },
- ],
- };
- const formOption = reactive({
- readonly: false, //用于控制整个表单是否只读
- disabled: false,
- labelAlign: "top",
- scroll: true,
- labelWidth: "62pk",
- submitBtnText: proxy.t("receive.confirmReceipt"),
- otherBtn: false,
- otherBtnText: "退回前道工序",
- btnConfig: {
- isNeed: false,
- prop: "list",
- plain: true,
- listTitle: "",
- listConfig: [],
- clickFn: () => {},
- },
- });
- const formConfig = reactive([
- {
- type: "input",
- itemType: "text",
- label: proxy.t("receive.productName"),
- prop: "productName",
- readonly: true,
- },
- {
- type: "input",
- itemType: "text",
- label: "规格型号",
- prop: "productSpec",
- readonly: true,
- },
- {
- type: "input",
- itemType: "text",
- label: proxy.t("receive.productSN"),
- prop: "productSn",
- readonly: true,
- },
- {
- type: "slot",
- itemType: "textarea",
- label: "产品备注",
- slotName: "productRemark",
- readonly: true,
- },
- {
- type: "input",
- itemType: "text",
- label: "当前工序",
- prop: "productionProcessesName",
- readonly: true,
- },
- {
- type: "slot",
- label: "生产工序资料",
- slotName: "fileTwo",
- },
- {
- type: "slot",
- label: "工单附件",
- slotName: "fileThree",
- },
- {
- type: "upload",
- label: "完工拍摄",
- prop: "fileList",
- showUpload: false,
- },
- {
- type: "input",
- itemType: "text",
- label: proxy.t("receive.previousProcess"),
- prop: "previousProcessesName",
- readonly: true,
- },
- {
- type: "input",
- itemType: "text",
- label: "流转人",
- prop: "circulationUserName",
- readonly: true,
- },
- ]);
- const onClickLeft = () => history.back();
- const onSubmit = () => {
- proxy
- .post("/productionTaskDetail/haveTaskCount", {
- productionProcessesId: formData.data.productionProcessesId,
- })
- .then((res) => {
- if (res.data && Number(res.data) > 0) {
- showConfirmDialog({
- title: "提示",
- message: "你当前还有进行中的任务尚未提交,确认接收新任务吗?",
- })
- .then(() => {
- showConfirmDialog({
- title: "提示",
- message: "你当前还有进行中的任务尚未提交,确认接收新任务吗?",
- })
- .then(() => {
- submitApi();
- })
- .catch(() => {
- return;
- });
- })
- .catch(() => {
- return;
- });
- } else {
- submitApi();
- }
- });
- };
- const submitApi = () => {
- proxy.post("/productionTaskDetail/receive", { id: formData.data.id }).then(
- (res) => {
- setTimeout(() => {
- showSuccessToast(proxy.t("common.operationSuccessful"));
- proxy.$router.push("/main/jxskReceive");
- }, 500);
- },
- (err) => {
- return showFailToast(err.message);
- }
- );
- };
- const otherBtnClick = () => {
- proxy.post("/productionTaskDetail/rejection", { id: formData.data.id }).then(
- (res) => {
- setTimeout(() => {
- showSuccessToast(proxy.t("common.operationSuccessful"));
- proxy.$router.push("/main/jxskReceive");
- }, 500);
- },
- (err) => {
- return showFailToast(err.message);
- }
- );
- };
- const getDetails = () => {
- proxy.post("/productionTaskDetail/detail", { id: route.query.id }).then(
- (res) => {
- if (
- res.data.productionTaskDetailRecordList &&
- res.data.productionTaskDetailRecordList.length > 0
- ) {
- let id = res.data.previousProcessesRecordId;
- proxy
- .post("/fileInfo/getList", { businessIdList: [id] })
- .then((res) => {
- if (res.data[id] && res.data[id].length > 0) {
- formData.data.fileList = res.data[id].map((item) => {
- return {
- raw: item,
- name: item.fileName,
- url: item.fileUrl,
- };
- });
- }
- });
- }
- proxy
- .post("/fileInfo/getList", {
- businessIdList: [res.data.productionProcessesId],
- })
- .then((resOne) => {
- if (
- resOne.data[res.data.productionProcessesId] &&
- resOne.data[res.data.productionProcessesId].length > 0
- ) {
- formData.data.fileListTwo = resOne.data[
- res.data.productionProcessesId
- ].map((item) => {
- return {
- raw: item,
- name: item.fileName,
- url: item.fileUrl,
- };
- });
- }
- });
- proxy
- .post("/fileInfo/getList", {
- businessIdList: [res.data.workOrderId],
- fileType: 1,
- })
- .then((resOne) => {
- if (
- resOne.data[res.data.workOrderId] &&
- resOne.data[res.data.workOrderId].length > 0
- ) {
- formData.data.fileListThree = resOne.data[res.data.workOrderId].map(
- (item) => {
- return {
- raw: item,
- name: item.fileName,
- url: item.fileUrl,
- };
- }
- );
- }
- });
- },
- (err) => {
- return showFailToast(err.message);
- }
- );
- };
- onMounted(() => {
- if (route.query.id) {
- formData.data = { ...route.query };
- getDetails();
- if (
- !formData.data.previousProcessesId ||
- formData.data.previousProcessesId == -1
- ) {
- formOption.otherBtn = false;
- }
- }
- });
- const onPreviewFile = (item) => {
- uni.postMessage({
- data: {
- type: "file",
- url: item.url,
- name: item.name,
- },
- });
- };
- </script>
- <style lang="scss" scoped>
- .row {
- display: flex;
- padding: 5px 10px 0 10px;
- justify-content: space-between;
- align-items: center;
- .title {
- flex: 1;
- }
- .delete {
- width: 20px;
- cursor: pointer;
- text-align: center;
- }
- }
- </style>
|