| | |
| | | |
| | | import { createVNode, render, h, reactive } from 'vue'; |
| | | import { ElDialog, ElForm, ElFormItem, ElSelect, ElOption, ElButton, ElMessage, ElLoading } from 'element-plus'; |
| | | import gridHeader from './extend/CrossAreaRelocationDialog.vue' |
| | | let extension = { |
| | | components: { |
| | | //æ¥è¯¢ç颿©å±ç»ä»¶ |
| | | gridHeader: '', |
| | | gridHeader: gridHeader, |
| | | gridBody: '', |
| | | gridFooter: '', |
| | | //æ°å»ºãç¼è¾å¼¹åºæ¡æ©å±ç»ä»¶ |
| | |
| | | } |
| | | } |
| | | }) |
| | | |
| | | let SelectTake = this.buttons.find(x => x.value == 'SelectStockTake'); |
| | | if (SelectTake) { |
| | | // æ¹ä¸ºç®å¤´å½æ°ç¡®ä¿thisæåVueç»ä»¶å®ä¾ |
| | | SelectTake.onClick = async () => { |
| | | // è·åé䏿°æ®ï¼ä¸åé»è¾ä¸è´ï¼ç¡®ä¿æ¯æ°ç»æ ¼å¼ï¼ |
| | | let stockViews = this.$refs.table.getSelected(); |
| | | |
| | | // æ°æ®æ ¡éªï¼è³å°éæ©ä¸æ¡æ°æ® |
| | | if (stockViews.length === 0) return ElMessage.error("è¯·éæ©éè¦æä½çæ°æ®!"); |
| | | |
| | | // ç«å°é项ï¼å¯æ ¹æ®å®é
ä¸å¡è°æ´é项å¼ï¼ |
| | | const stationOptions = [ |
| | | { label: "ç«å°2", value: "2-1" }, |
| | | { label: "ç«å°3", value: "3-1" }, |
| | | { label: "ç«å°4", value: "4-1" }, |
| | | ]; |
| | | |
| | | // åå»ºå¼¹çªæè½½èç¹ |
| | | const mountNode = document.createElement("div"); |
| | | document.body.appendChild(mountNode); |
| | | |
| | | // è¡¨åæ°æ®ï¼ç»å®éä¸çç«å°ï¼ |
| | | const formData = reactive({ |
| | | outStation: stationOptions[0].value, // é»è®¤éä¸ç¬¬ä¸ä¸ªç«å° |
| | | }); |
| | | |
| | | // å建弹çªVNode |
| | | const vnode = createVNode( |
| | | ElDialog, |
| | | { |
| | | title: "åºåæä½ - éæ©åºåºç«å°", |
| | | width: "500px", |
| | | modelValue: true, |
| | | appendToBody: true, |
| | | "onUpdate:modelValue": (isVisible) => { |
| | | if (!isVisible) { |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | } |
| | | }, |
| | | style: { |
| | | padding: "20px 0", |
| | | borderRadius: "8px", |
| | | }, |
| | | }, |
| | | { |
| | | default: () => |
| | | h( |
| | | ElForm, |
| | | { |
| | | model: formData, |
| | | rules: { |
| | | outStation: [ |
| | | { required: true, message: "è¯·éæ©åºåºç«å°", trigger: "change" }, |
| | | ], |
| | | }, |
| | | ref: "stockTakeForm", // 表årefæ è¯ |
| | | labelWidth: "100px", |
| | | style: { |
| | | padding: "0 30px", |
| | | }, |
| | | }, |
| | | [ |
| | | // ç«å°éæ©ä¸ææ¡ |
| | | h(ElFormItem, { |
| | | label: "åºåºç«å°", |
| | | prop: "outStation", |
| | | style: { marginBottom: "24px" }, |
| | | }, [ |
| | | h(ElSelect, { |
| | | placeholder: "è¯·éæ©åºåºç«å°", |
| | | modelValue: formData.outStation, |
| | | "onUpdate:modelValue": (val) => { |
| | | formData.outStation = val; |
| | | }, |
| | | style: { |
| | | width: "100%", |
| | | height: "40px", |
| | | borderRadius: "4px", |
| | | borderColor: "#dcdfe6", |
| | | }, |
| | | }, stationOptions.map((station) => |
| | | h(ElOption, { label: station.label, value: station.value }) |
| | | )), |
| | | ]), |
| | | // åºé¨æé®åºå |
| | | h("div", { |
| | | style: { |
| | | textAlign: "right", |
| | | marginTop: "8px", |
| | | paddingRight: "4px", |
| | | }, |
| | | }, [ |
| | | // åæ¶æé® |
| | | h(ElButton, { |
| | | type: "text", |
| | | onClick: () => { |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | ElMessage.info("åæ¶åºåæä½"); |
| | | }, |
| | | style: { marginRight: "8px", color: "#606266" }, |
| | | }, "åæ¶"), |
| | | // ç¡®å®æé® |
| | | h(ElButton, { |
| | | type: "primary", |
| | | onClick: async () => { |
| | | // ç¡®ä¿è¡¨årefå·²æè½½ |
| | | await this.$nextTick(); |
| | | const formRef = vnode.component.refs.stockTakeForm; |
| | | |
| | | if (!formRef) { |
| | | ElMessage.error("表ååå§å失败ï¼è¯·éè¯"); |
| | | return; |
| | | } |
| | | |
| | | // 表åéªè¯ |
| | | try { |
| | | await formRef.validate(); |
| | | } catch (err) { |
| | | return; |
| | | } |
| | | |
| | | const requestBody = stockViews; |
| | | const outStation = formData.outStation; |
| | | |
| | | try { |
| | | |
| | | const url = `api/Task/TakeOutbound?outStation=${encodeURIComponent(outStation)}`; |
| | | |
| | | const x = await this.http.post( |
| | | url, // 带æ¥è¯¢åæ°çURL |
| | | requestBody, // 请æ±ä½ï¼stockViewsæ°ç» |
| | | "æ°æ®å¤çä¸" |
| | | ); |
| | | |
| | | if (!x.status) { |
| | | ElMessage.error(x.message || "åºåæä½å¤±è´¥"); |
| | | return; |
| | | } |
| | | |
| | | ElMessage.success("æä½æå"); |
| | | this.refresh(); // åå·æ°é»è¾ä¿ç |
| | | } catch (error) { |
| | | console.error("åºåæ¥å£è¯·æ±å¤±è´¥ï¼", error); |
| | | ElMessage.error("请æ±å¤±è´¥ï¼è¯·ç¨åéè¯"); |
| | | } finally { |
| | | // æ 论æå失败ï¼å
³éå¼¹çª |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | } |
| | | }, |
| | | style: { borderRadius: "4px", padding: "8px 20px" }, |
| | | }, "ç¡®å®æä½"), |
| | | ]), |
| | | ]), |
| | | } |
| | | ); |
| | | |
| | | // ç»å®appä¸ä¸æï¼ç¡®ä¿å¼¹çªå
ç»ä»¶æ£å¸¸å·¥ä½ï¼ |
| | | vnode.appContext = this.$.appContext; |
| | | render(vnode, mountNode); |
| | | }; |
| | | } |
| | | let SelectTakeArea = this.buttons.find(x => x.value == 'SelectStockAreaOut'); |
| | | if (SelectTakeArea) { |
| | | SelectTakeArea.onClick = function () { |
| | | let stockViews = this.$refs.table.getSelected(); |
| | | this.http |
| | | .post("api/Task/AreaOutbound",stockViews, "æ°æ®å¤çä¸") |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | | this.refresh(); |
| | | }); |
| | | } |
| | | } |
| | | var SelectStockAreaIn = this.buttons.find(x => x.value == "SelectStockAreaIn"); |
| | | if (SelectStockAreaIn != null) { |
| | | SelectStockAreaIn.onClick = () => { |
| | | let rows = this.$refs.table.getSelected(); |
| | | if (rows.length == 0) { |
| | | return this.$message.error("请å
éæ©éè¦ç§»åºçæ°æ®ï¼"); |
| | | } |
| | | this.$refs.gridHeader.open(); |
| | | } |
| | | } |
| | | }, |
| | | onInited() { |
| | | //æ¡æ¶åå§åé
ç½®å |