Ant design Vue中的a-select赋值取值

本文详细讲述了在Vue中如何实现下拉框的选择项数据从数据库获取并回显,重点介绍了使用$set方法确保数据正确同步的技巧。


前言

记录一下,就是一个下拉框,里面的待选数据由数据库里来,并且选完保存后还能回显,主要记录的是回显操作,与我之前写的文章大同小异。

一、.vue

1.template

<a-form :form="Form" >
<a-form-item>
//注意下面的v-model,不是直接一个数组
	<a-select v-model="Form.dataAuth" >
		<a-select-option v-for="item in list":value="item.key" :key="item.key">
			{{ item.title }}
		</a-select-option>
	</a-select>
</a-form-item>
</a-form>

2.data

data () {
	return {
      list: [],
      Form: {
        dataAuth: []
		}
	}
}

3.created

created () {
   this.show()
}

4.下拉框选项

methods: {
	show(){
	//xxxxxxxxx是后端工程师给你的接口,也可以在JS里写,之后引进来使用
		query(xxxxxxxxx).then(res => {
        const result = res.result.data
        result.forEach((res) => {
          this.list.push({ 'key':res.key, 'title':res.title })
        })
      })
    },
}

在这里插入图片描述

5.※回显※

methods: {
show1() {
	query(xxxxxxxxx).then(res => {
		this.$set(this.Form, 'dataAuth', res.result.data)
        })
    }
}

在这里插入图片描述
这是后端工程师给你的,他将以这种样子返回给你数据
在这里插入图片描述

总结

像这样直接赋值,有时候不显示,最好还是.$set(),不知原因

this.addForm.dataAuth = ress.result.data

像这样两层的,给dataAuth;[]初值也不好使,如果把dataAuth;[]单拿出来,赋初值就好使,不知原因

  Form: {
    dataAuth: []
	}

好了姐妹们,bye~~~

<template> <c-search-panel ref="searchPanelRef" :columns="tableState.columns.concat(extraColumns)" @search="onSearch"> <template #workzoneSearch="{ slotScope }"> <a-select showSearch allowClear v-model:value="slotScope.workzoneNo" :options="workzoneSearchList" :filter-option="filterOption" @click="handleWorkzoneClick"> </a-select> </template> </c-search-panel> <c-table :columns="tableState.columns" :proxy-config="tableState.proxyConfig" :toolbar="tableState.toolbar" :rowSelection="rowSelection" @toolbar-button-click="onToolbarClick" :sortConfig="{ showIcon: false }" :pagination="tableState.pagination" rowKey="orderNo" ref="tableRef" > <template #action="{ record }"> <a-button type="link" @click="viewDetail(record)">查看</a-button> <!-- <a-button type="link" @click="cutOrder(record)">下料单</a-button>--> <!-- <a-button type="link" @click="materialOrder(record)">材料单</a-button>--> <!-- <a-button type="link" @click="nestingMaterialOrder(record)">套料件材料单</a-button>--> <a-button type="link" @click="materialApply(record)"> 材料申请 </a-button> <a-button type="link" @click="printDraw(record)">打印图纸</a-button> <!-- <a-button type="link" @click="routingCard(record)">打印流转卡</a-button>--> <!-- <a-button type="link" @click="electronicTag(record)">电子标牌</a-button>--> </template> </c-table> <c-modal :title="'反馈详情'" v-model:open="open" destroyOnClose ref="modalRef" :footer="null"> <c-table :columns="tableFeedbackPipeState.columns" :data-source="feedbackPipeData" :pagination="false" :sortConfig="{ showIcon: false }" :height="400" ref="tableRef" > <template #action="{ record }"> <a-button type="link" @click="viewDraw(record.drawFilePath)">查看图纸</a-button> <a-button type="link" @click="pipeLog(record)">查看日志</a-button> <a-button type="link" @click="exceptionSubmit(record)">异常上报</a-button> </template> </c-table> </c-modal> <c-modal v-model:open="modalVisible" title="计划派工" @ok="handleOk" :width="500" > <a-form ref="formRef" :model="formState" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }" > <a-form-item label="预制计划" name="planNoList"> <a-select v-model:value="formState.planNoList" mode="multiple" style="width: 258px"> <a-select-option v-for="(item, index) in planList" :key="index" :value="item.planNo"> {{ item.planNo }} </a-select-option> </a-select> </a-form-item> <a-form-item label="日期" name="selectedDateRange"> <a-range-picker v-model:value="formState.selectedDateRange" :placeholder="['开始日期', '结束日期']" value-format="YYYY-MM-DD" :disabledDate="disabledDate" /> </a-form-item> </a-form> </c-modal> <c-modal :title="'异常上报'" v-model:open="exceptionVisible" destroyOnClose okText="确认" cancelText="取消" @ok="submitException" width="20%" > <a-form ref="exceptionFormRef" :model="exceptionFormState" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }"> <a-form-item label="异常类型" name="exceptionType" :rules="[{ required: true, message: '请选择异常类型' }]" > <a-select showSearch allow-clear v-model:value="exceptionFormState.exceptionType"> <a-select-option v-for="(item, index) in exceptionTypeList" :key="index" :value="item.name"> {{ item.name }} </a-select-option> </a-select> </a-form-item> <a-form-item label="异常描述" name="exceptionMsg" :rules="[{ required: true, message: '请输入异常描述' }]" > <a-textarea :rows="4" v-model:value="exceptionFormState.exceptionMsg" /> </a-form-item> </a-form> </c-modal> <c-modal :title="'操作日志'" v-model:open="logVisible" destroyOnClose :footer="null"> <c-table :columns="tableLogState.columns" :toolbar="tableLogState.toolbar" :proxy-config="tableLogState.proxyConfig" :pagination="tableLogState.pagination" :sortConfig="{ showIcon: false }" :height="400" ref="tableRef" > </c-table> </c-modal> <c-modal v-model:open="materialApplyVisible" title="材料申请" @ok="handleOk" destroyOnClose > <a-form ref="formRef" :model="materialApplyFormState" :rules="materialApplyRules" ref="materialApplyFormRef" :label-col="{ span: 6 }"> <a-form-item label="基地" name="orgNo"> <c-build-case-select v-model:value="materialApplyFormState.orgNo" :fieldNames="fieldNames" @change="changeOrg"/> </a-form-item> <a-form-item label="送达位置" name="serviceLocationId"> <a-select showSearch allowClear :options="locationList" :filter-option="filterOption" v-model:value="materialApplyFormState.serviceLocationId" @change="changeLocation" > <a-select-option :value="item.id" v-for="item in locationList" :key="item.id">{{ item.name }}</a-select-option> </a-select> </a-form-item> <a-form-item label="接收人" name="receiverId"> <a-select showSearch allowClear :options="receiveUserList" :filter-option="filterOption" v-model:value="materialApplyFormState.receiverId" @change="changeReceiver" > <a-select-option :value="item.id" v-for="item in receiveUserList" :key="item.id">{{ item.receiver }}</a-select-option> </a-select> </a-form-item> <a-form-item label="联系方式" name="receiverTel"> <a-input v-model:value="materialApplyFormState.receiverTel" /> </a-form-item> </a-form> </c-modal> </template> <script setup> import * as server from "@/packages/piping/api/cppf" import { computed, reactive, ref, onMounted } from "vue" import { validateSearchFields } from "@/utils" import { message } from "ant-design-vue" import dayjs from "dayjs" import { useRouter } from "vue-router" import { useI18n } from "vue-i18n" import { postExceptionManage } from "@/packages/piping/api/exceptionManage" import {getWorkZone, pipeLogPage} from "@/packages/piping/api/basic" import { getDislist } from "@/packages/oem/api/co" import { debounce } from "lodash-es" const { t } = useI18n() const router = useRouter() const tableState = reactive({ toolbar: { buttons: [ { code: "exportExcel", status: 'warning', icon: 'DownloadOutlined', name: "导出" }, { code: "planCreateOrder", status: "primary", icon: "ScheduleOutlined", name: "计划派工" }, { code: "printAllReport", status: "primary", icon: "PrinterOutlined", name: "打印" }, // { // code: "printDraws", // status: "primary", // icon: "DeploymentUnitOutlined", // name: "打印图纸" // }, { code: "printCuttingList", status: "primary", icon: "PrinterOutlined", name: "打印下料单" }, { code: "printMaterialList", status: "primary", icon: "PrinterOutlined", name: "打印材料单" }, { code: "printNestingList", status: "primary", icon: "PrinterOutlined", name: "打印套料材料单" }, { code: "printPreTransferOrder", status: "primary", icon: "PrinterOutlined", name: "打印流转卡" }, { code: "materialMoreApply", status: "primary", icon: "PrinterOutlined", name: "材料申请" }, { code: "download", status: "primary", icon: "DownloadOutlined", name: "下载" }, { code: "printRfid", status: "primary", icon: "PrinterOutlined", name: "电子标牌打印", resource: [{ url: "/service-piping/cp/pipe/pre/work/order/rfidPrintInfo", method: "POST" }] } ], showFilter: false }, pagination: { pageSize: 20 }, proxyConfig: { autoLoad: false, ajax: { query: async (pagination) => { conditionData = await validateSearchFields(searchPanelRef, conditionData) return server.workOrderPage({ ...pagination, ...conditionData }) } } }, columns: [ { title: "项目", dataIndex: "projectNo", width: 80, type: "project", options: { options: [], fieldNames: { label: "projId", value: "projId" } } }, { title: "派工单号", dataIndex: "orderNo", width: 120, condition: true, conditionNotice: t("pipeControll.search.content") }, { title: "基地", dataIndex: "orgNo", type: "buildCase", width: 80, condition: true }, { title: "派工类型", dataIndex: "orderType", type: "select", width: 100, options: { options: [ {value: '普通', label: "普通"}, {value: '船校返回', label: "船校返回"}, {value: '原管修改', label: "原管修改"}, {value: '再现机', label: "再现机"}, ] }, }, { title: "总长度", dataIndex: "totalLength", width: 70 }, { title: "总重量", dataIndex: "totalWeight", width: 70 }, { title: "总寸口数", dataIndex: "totalInch", width: 80 }, { title: "物量统计", dataIndex: "pipeCount", width: 80 }, { title: "下料工位号", dataIndex: "cutWorkSpaceNo", width: 80 }, { title: "下料开始日期", dataIndex: "cutStartDate", type: "date", width: 100 }, { title: "下料结束日期", dataIndex: "cutEndDate", type: "date", width: 100 }, { title: "下料状态", dataIndex: "cutStatus", width: 80, type: "select", options: { options: [ { value: "Y", label: "Y" }, { value: "N", label: "N" } ] } }, { title: "装配工位号", dataIndex: "assyWorkSpaceNo", width: 80 }, { title: "装配工位类型", dataIndex: "assyWorkSpaceType", width: 100 }, { title: "装配开始日期", dataIndex: "assyStartDate", type: "date", width: 100 }, { title: "装配结束日期", dataIndex: "assyEndDate", type: "date", width: 100 }, { title: "装配状态", dataIndex: "assyStatus", width: 80, type: "select", options: { options: [ { value: "Y", label: "Y" }, { value: "N", label: "N" } ] } }, { title: "焊接工位号", dataIndex: "weldingWorkSpaceNo", width: 80 }, { title: "焊接工位类型", dataIndex: "weldingWorkSpaceType", width: 100 }, { title: "焊接开始日期", dataIndex: "weldingStartDate", type: "date", width: 100 }, { title: "焊接结束日期", dataIndex: "weldingEndDate", type: "date", width: 100 }, { title: "焊接状态", dataIndex: "weldingStatus", width: 80, type: "select", options: { options: [ { value: "Y", label: "Y" }, { value: "N", label: "N" } ] } }, { title: "派工单状态", dataIndex: "status", width: 100, type: "select", formatter: (data) => data.cellValue == -1 ? "作废" : data.cellValue == 0 ? "新建" : data.cellValue == 1 ? "作业中" : data.cellValue == 2 ? "已完成" : "", options: { options: [ { value: -1, label: "作废" }, { value: 0, label: "新建" }, { value: 1, label: "作业中" }, { value: 2, label: "已完成" } ] } }, { title: "下料领料单号", dataIndex: "cutMatListNo", width: 120 }, { title: "装配领料单号", dataIndex: "assyMatListNo", width: 120 }, { title: "创建人", dataIndex: "createUserNo", type: "employeeDescription", options: { fieldNames: { label: "createUserName", value: "createUserNo" } }, width: 110 }, { title: "创建时间", dataIndex: "createDataDate", formatter: ({ row }) => { return row.createDate ? dayjs(row.createDate).format("YYYY-MM-DD") : "-" }, width: 80, invisible: false, type: "date" }, { title: "操作", key: "action", scopedSlots: { customRender: "action" }, width: 240, fixed: "right", formInvisible: true } ] }) const extraColumns = ref([ { title: "项目", dataIndex: "projectNo", width: 80, condition: true, type: "project", options: { options: [], fieldNames: { label: "projId", value: "projId" } } }, { title: "作业区", dataIndex: "workzoneNo", width: 120, condition: true, type: "select", formatter: ({row}) => row.workzoneName, scopedSlots: { customSearchRender: "workzoneSearch" }, }, { title: "创建时间", dataIndex: "createDate", width: 80, condition: true, type: "date" }, { title: "小票号", dataIndex: "pipeNoList", width: 120, condition: true, conditionNotice: t("pipeControll.search.content") }, ]) const feedbackPipeData = ref([]) const tableFeedbackPipeState = reactive({ columns: [ { title: "项目", dataIndex: "projectNo", width: 50, condition: true, type: "project", options: { options: [], fieldNames: { label: "projId", value: "projId" } } }, { title: "图号", dataIndex: "drawNo", width: 170 }, { title: "作业对象", dataIndex: "block", width: 70 }, { title: "小票号", dataIndex: "pipeNo", width: 150 }, { title: "版本号", dataIndex: "pipeVersion", width: 60 }, { title: "最新版", dataIndex: "isTopVersion", width: 60, type: "select", options: { options: [ { label: "Y", value: "Y" }, { label: "N", value: "N" } ] } }, { title: "是否删除", dataIndex: "isDelete", width: 80, type: "select", options: { options: [ { label: "Y", value: "Y" }, { label: "N", value: "N" } ] } }, { title: "是否暂停", dataIndex: "isPause", width: 80, type: "select", options: { options: [ { label: "Y", value: "Y" }, { label: "N", value: "N" } ] } }, { title: "下料定额工时", dataIndex: "cutQuotaWorkhour", width: 100 }, { title: "装配定额工时", dataIndex: "assyQuotaWorkhour", width: 100 }, { title: "焊接定额工时", dataIndex: "weldingQuotaWorkhour", width: 100 }, { title: "下料完成时间", dataIndex: "realCutFinishDate", type: "date", width: 100 }, { title: "装配完成时间", dataIndex: "realAssyFinishDate", type: "date", width: 100 }, { title: "焊接完成时间", dataIndex: "realWeldingFinishDate", type: "date", width: 100 }, { title: "操作", key: "action", scopedSlots: { customRender: "action" }, width: 240, fixed: "right", formInvisible: true } ] }) const workzoneSearchList = ref([]) const tableRef = ref(null) const formRef = ref() const searchPanelRef = ref(null) const searchForm = computed(() => { if (searchPanelRef.value) { return searchPanelRef.value.getForm() } return null }) const modalRef = ref(null) const ctable = computed(() => tableRef.value?.getTable()) let conditionData = {} const open = ref(false) const modalVisible = ref(false) const planList = ref([]) const formState = reactive({ planNoList: [], selectedDateRange: [] }) const today = dayjs().startOf("day") const disabledDate = (current) => { return current && current < today } const fieldNames = ref({ value: 'orgNo', label: 'name' }) const materialApplyVisible = ref(false) const rules = { planNoList: [{ required: true, message: "请选择预制计划" }], selectedDateRange: [{ required: true, message: "请选择日期" }] } const materialApplyRules = { orgNo: [{ required: true, message: "请选择基地" }], serviceLocationId: [{ required: true, message: "请选择送达位置" }], receiverId: [{ required: true, message: "请选择接收人" }], } const materialApplyFormRef = ref() const materialApplyFormState = reactive({ orgNo: "", serviceLocationId: "", receiverId: "", receiverTel: "" }) const locationList = ref([]) const receiveUserList = ref([]) const rowSelection = computed(() => { return { type: "checkbox", // 确保是多选模式 selectedRowKeys: tableState.selectedRowKeys, onChange: (selectedRowKeys, selectedRows, event) => { tableState.selectedRowKeys = selectedRowKeys tableState.selectedRows = selectedRows // 保存选中的行数据 console.log("onChange", selectedRowKeys, selectedRows, event) }, onSelect: (record, selected, selectedRows, nativeEvent) => { tableState.selectedRows = selectedRows // 更新选中的行数据 console.log("onSelect", record, selected, selectedRows, nativeEvent) }, onSelectAll: (selected, selectedRows, changeRows) => { tableState.selectedRows = selectedRows // 更新选中的行数据 console.log("onSelectAll", selected, selectedRows, changeRows) } } }) const conditionLogData = ref() const logVisible = ref(false) const tableLogState = reactive({ toolbar: {}, selectedRowKeys: [], pagination: { pageSize: 20, pageSizeOptions: [20, 100, 400] }, proxyConfig: { autoLoad: true, ajax: { query: (pagination) => pipeLogPage({ ...pagination, ...conditionLogData.value }) } }, columns: [ { title: "操作时间", dataIndex: "createDate", type: "datetime" }, { title: "操作人", dataIndex: "createUserNo", type: "employeeDescription", align: "center", options: { fieldNames: { label: "createUserName", value: "createUserNo" } }, width: 100 }, { title: "操作类型", dataIndex: "event" }, { title: "操作详情", dataIndex: "msg" } ] }) const localStorage = window.localStorage const projectNo = ref("") const pipeNo = ref("") const pipeVersion = ref(null) const orgNo = ref("") const exceptionVisible = ref(false) const exceptionTypeList = ref([]) const exceptionFormRef = ref() const exceptionFormState = ref({ exceptionType: "", exceptionMsg: "" }) const isSubmitting = ref(false) const onToolbarClick = (target) => { switch (target.code) { case "exportExcel": funExportModal() break case "planCreateOrder": planCreateOrder() break case "printMaterialList": printMaterialList() break case "printCuttingList": printCuttingList() break case "printNestingList": printNestingList() break case "printPreTransferOrder": printPreTransferOrder() break case "printAllReport": printAllReport() break case "download": download() break case "printRfid": printRfid() break // case "printDraws": // download() // breakprintDraws default: break } } const changeOrg = (orgNo) => { materialApplyFormState.serviceLocationId = "" materialApplyFormState.receiverId = "" materialApplyFormState.receiverTel = "" server.getLocationDropList({ orgNo: orgNo }).then(res => { locationList.value = res.data; }); } const changeLocation = (locationId) => { server.getLocationDropList({ id: locationId, }).then(res => { receiveUserList.value = res.data[0].receiverList; if (receiveUserList.value && receiveUserList.value.length > 0) { materialApplyFormState.receiverId = receiveUserList.value[0].id; materialApplyFormState.receiverTel = receiveUserList.value[0].receiverTel; } }) } const changeReceiver = (receiverId) => { const matchedUser = receiveUserList.value.find(user => user.id == receiverId); if (matchedUser) { materialApplyFormState.receiverTel = matchedUser.receiverTel; } } const handleWorkzoneClick = () => { workzoneSearchList.value = [] const searchFormValues = searchForm.value?.getFieldsValue() if (!searchFormValues.orgNo) { return } getWorkZone({majors: "管路", orgNo: searchFormValues.orgNo}).then((res) => { workzoneSearchList.value = res.data.map(item => { return { label: item.name, value: item.code } }) }) } // 打印材料单函数 const printMaterialList = async () => { try { // 验证选择 if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } // 获取派工单号 const orderNos = tableState.selectedRows .map(row => row.orderNo) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } router.push({ path: "/piping/cppf/preAssyOrder", query: { orderNos: orderNos.join(",") } }) } catch (error) { console.error("打印材料单失败:", error) message.error("打印失败,请重试") } } // 打印下料单函数 const printCuttingList = async () => { try { // 验证选择 if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } // 获取派工单号 const orderNos = tableState.selectedRows .map(row => row.orderNo) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } router.push({ path: "/piping/cppf/preCutOrder", query: { orderNos: orderNos.join(",") } }) } catch (error) { console.error("打印下料单失败:", error) message.error("打印失败,请重试") } } // 打印套料材料单 const printNestingList = async () => { try { // 验证选择 if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } // 获取派工单号 const orderNos = tableState.selectedRows .map(row => row.orderNo) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } router.push({ path: "/piping/cppf/preNestingOrder", query: { orderNos: orderNos.join(",") } }) } catch (error) { console.error("打印套料材料单失败:", error) message.error("打印失败,请重试") } } // 打印 const printAllReport = async () => { try { // 验证选择 if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } // 获取派工单号 const orderNos = tableState.selectedRows .map(row => row.orderNo) // 获取项目编号 const projetNos = tableState.selectedRows.map(row => row.projectNo) const totalLengths = tableState.selectedRows.map(row => row.totalLength) const totalWeights = tableState.selectedRows.map(row => row.totalWeight) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } router.push({ path: "/piping/cppf/cpPipeAllReport", query: { orderNos: orderNos.join(","), projetNos: projetNos.join(","), totalLengths: totalLengths.join(","), totalWeights: totalWeights.join(",") } }) } catch (error) { message.error("打印失败,请重试") } } // 打印 // const printDraws = async () => { // try { // if (!tableState.selectedRows?.length) { // message.warning("请至少选择一条数据") // return // } // const orderNos = tableState.selectedRows // .map(row => row.orderNo) // .filter(Boolean) // 过滤空值 // if (!orderNos.length) { // message.warning("未找到有效的派工单号") // return // } // const token = localStorage.getItem("token") // const searchParams = new URLSearchParams() // searchParams.append('orderNos', orderNos) // searchParams.append('token', token) // const baseUrl = "http://epc/api/service-piping/cp/pipe/pre/work/order/printDraws" // const fullUrl = `${baseUrl}?${searchParams.toString()}` // window.open(fullUrl) // } catch (error) { // console.error('打印失败:', error) // message.error("打印失败,请重试") // } // } const printRfid = async () => { try { // 验证选择 if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } // 获取派工单号 const orderNos = tableState.selectedRows .map(row => row.orderNo) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } router.push({ path: "/piping/cppf/cpPipePrint", query: { orderNos: orderNos.join(",") } }) } catch (error) { message.error("打印失败,请重试") } } // 下载 const download = async () => { try { if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } const orderNos = tableState.selectedRows .map(row => row.orderNo) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } await server.downloadworkOrder(orderNos); } catch (error) { console.error("下载失败:", error) message.error("下载失败,请重试") } } onMounted(() => { getDislist({ code: "CP_EXCEPTION_TYPE" }).then((res) => { exceptionTypeList.value = res.data }) }) //搜索 const onSearch = () => { ctable.value.commitProxy("reload") } const viewDetail = (record) => { open.value = true orgNo.value = record.orgNo server.workOrderPipeDetail({ orderNo: record.orderNo, projectNo: record.projectNo }).then((res) => { feedbackPipeData.value = res.data }) } // const cutOrder = (record) => { // router.push({ // path: "/piping/cppf/preCutOrder", // query: { // orderNo: record.orderNo // } // }) // } // const materialOrder = (record) => { // router.push({ // path: "/piping/cppf/preAssyOrder", // query: { // orderNo: record.orderNo // } // }) // } // const nestingMaterialOrder = (record) => { // router.push({ // path: "/piping/cppf/preNestingOrder", // query: { // orderNo: record.orderNo // } // }) // } const materialApply = (record) => { formRef.value.validate().then(() => { locationList.value.forEach(item => { if (item.id == materialApplyFormState.serviceLocationId) { record.serviceLocationName = item.name; } }); receiveUserList.value.forEach(item => { if (item.id == materialApplyFormState.receiverId) { record.receiverCode = item.receiverId; } }); const applyData = { orderNo: record.orderNo, orgNo: materialApplyFormState.orgNo, locationOrgName: "", receiverCode: record.receiverCode, receiverId: materialApplyFormState.receiverId, receiverTel: materialApplyFormState.receiverTel, serviceLocationId: materialApplyFormState.serviceLocationId, serviceLocationName: record.serviceLocationName, }; server.orderMaterialReq(applyData).then(() => { message.success("申请成功") }) }) } const printPreTransferOrder = () => { try { if (!tableState.selectedRows?.length) { message.warning("请至少选择一条数据") return } const orderNos = tableState.selectedRows .map(row => row.orderNo) .filter(Boolean) if (orderNos.length === 0) { message.warning("未找到有效的派工单号") return } router.push({ path: "/piping/cppf/preTransferOrder", query: { orderNos: orderNos.join(",") } }) } catch (error) { console.error("打印失败:", error) message.error("打印失败,请重试") } } // const electronicTag = (record) => { // router.push({ // path: "/piping/cppf/cpPipePrint", // query: { // orderNos: record.orderNo // } // }) // } const viewDraw = (drawFilePath) => { const encodedFilePath = encodeURIComponent(drawFilePath) const token = localStorage.getItem("token") window.open( `http://epc/api/service-piping/cp/pipe/design/info/getPcPipeDraw?drawFilePath=${encodedFilePath}&token=${token}` ); } const printDraw = (record) => { window.open( "http://epc/api/service-piping/cp/pipe/pre/work/order/printDraw?orderNo=" + record.orderNo + "&token=" + localStorage.getItem("token") ) } const planCreateOrder = () => { modalVisible.value = true formState.planNoList = [] formState.selectedDateRange = [] server.getPipePlanDropList({ isTopVersion: "Y", planType: "预制" }).then(res => { planList.value = res.data || [] }) } const handleOk = debounce(() => { if (isSubmitting.value) return formRef.value.validate().then(() => { isSubmitting.value = true const planIdList = planList.value .filter(p => formState.planNoList.includes(p.planNo)) .map(p => p.id) const [startDate, endDate] = formState.selectedDateRange const params = { planIdList, startDate, endDate } server.createPreOrder(params) .then(() => { message.success("派工成功") modalVisible.value = false ctable.value.commitProxy("reload") }) .catch((error) => { console.error("派工失败:", error) message.error("派工失败,请重试") }) .finally(() => { isSubmitting.value = false }) }).catch((error) => { console.error("表单验证失败:", error) message.error("请检查表单填写是否正确") isSubmitting.value = false }) }, 300) const exceptionSubmit = (record) => { exceptionFormState.value = { exceptionType: "", exceptionMsg: "" } projectNo.value = record.projectNo pipeNo.value = record.pipeNo pipeVersion.value = record.pipeVersion exceptionVisible.value = true } const submitException = () => { exceptionFormRef.value .validate().then(() => { const submitData = [{ projectNo: projectNo.value, bomNo: pipeNo.value, bomVersion: pipeVersion.value, orgNo: orgNo.value, exceptionType: exceptionFormState.value.exceptionType, exceptionMsg: exceptionFormState.value.exceptionMsg }] postExceptionManage(submitData).then(() => { message.success("上报成功") exceptionVisible.value = false }) }) } const pipeLog = (record) => { logVisible.value = true const logCondition = { projectNo: record.projectNo, pipeNo: record.pipeNo, pipeVersion: record.pipeVersion } conditionLogData.value = logCondition } const funExportModal = () => { searchForm.value.validateFields().then((values) => { server.preOrderExportExcel({...values}) }) } const filterOption = (input, option) => { return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 } </script> 其中const applyData = { orderNo: record.orderNo, orgNo: materialApplyFormState.orgNo, locationOrgName: "", receiverCode: record.receiverCode, receiverId: materialApplyFormState.receiverId, receiverTel: materialApplyFormState.receiverTel, serviceLocationId: materialApplyFormState.serviceLocationId, serviceLocationName: record.serviceLocationName, };的locationOrgName要取值filedNames里的label的值
最新发布
11-30
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

芥末加糖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值