From 25750ab29ce4e243f4e4e17a796167f3a0f0697b Mon Sep 17 00:00:00 2001 From: zs <zhousong@weben-smart.com> Date: 周一, 05 5月 2025 16:33:49 +0800 Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo --- Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/web/src/widgets/HIAWms/Controllers/WmsMaterialQueryDrawer.tsx | 296 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 296 insertions(+), 0 deletions(-) diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Weben_CMS_TemplateDemo/web/src/widgets/HIAWms/Controllers/WmsMaterialQueryDrawer.tsx" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Weben_CMS_TemplateDemo/web/src/widgets/HIAWms/Controllers/WmsMaterialQueryDrawer.tsx" new file mode 100644 index 0000000..8d9a9bd --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Weben_CMS_TemplateDemo/web/src/widgets/HIAWms/Controllers/WmsMaterialQueryDrawer.tsx" @@ -0,0 +1,296 @@ +import { + ref, + onMounted, + reactive, + computed, + Ref, + watch, + SetupContext, + h, +} from 'vue' +import { injectModel } from '@/libs/Provider/Provider' +import { WmsMaterialDrawer } from '../Models/WmsMaterialDrawer' +import { ElMessage } from 'element-plus' +import isEqual from 'lodash/isEqual' +import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox' +import { cloneDeep } from 'lodash' + +export const useWmsMaterialQueryDrawer = (props: any, ctx?: any) => { + const wmsMaterialDrawer = injectModel<WmsMaterialDrawer>('WmsMaterialDrawer') + /** + * 鐢ㄦ潵瀵规瘮鐨勫垵濮嬪寲鏁版嵁 + */ + const initiateData: Ref<Record<string, any>> = ref({}) + const formData = ref<Record<string, any>>({}) + // ref + const formRef = ref() + + const disabled = ref(false) + + const current = computed(() => { + return props.row || null + }) + + const inputNumber = (attrs) => { + return ( + <el-input-number + min="1" + step="1" + precision="0" + {...attrs} + ></el-input-number> + ) + } + + + const visible = computed({ + get() { + return props.modelValue + }, + set(val) { + ctx.emit('update:modelValue', val) + }, + }) + /** + * 娣诲姞鐨刦orm瀛楁 + */ + const formItems = reactive([ + { + label: '鐗╂枡缂栫爜', + prop: 'materialCode', + el: 'input', + disabled: disabled, + placeholder: '璇疯緭鍏ョ墿鏂欑紪鐮�', + }, + { + label: '鐗╂枡鍚嶇О', + prop: 'materialName', + el: 'input', + placeholder: '璇疯緭鍏ョ墿鏂欏悕绉�', + }, + { + label: '閲囪喘绫诲瀷', + prop: 'purchaseType', + el: 'select', + placeholder: '璇烽�夋嫨閲囪喘绫诲瀷', + options: [], + }, + { + label: '鐗╂枡绫诲瀷', + prop: 'materialType', + el: 'select', + placeholder: '璇烽�夋嫨鐗╂枡绫诲瀷', + options: [], + }, + { + label: '涓诲崟浣�', + prop: 'primaryUnit', + el: 'input', + placeholder: '璇疯緭鍏ヤ富鍗曚綅(濡�: kg, m, 涓�)', + }, + { + label: '瑙勬牸/鏍囧噯', + prop: 'standard', + el: 'input', + placeholder: '璇疯緭鍏ヨ鏍�/鏍囧噯(濡�: GB/T 8163-2018)', + }, + { + label: '澶栧緞(mm)', + prop: 'outerDiameter', + el: (props: any, { attrs }: SetupContext) => { + return h(inputNumber, { + ...props, + clearable: true, + ...attrs, + }) + }, + width: '100%', + placeholder: '璇疯緭鍏ュ寰�', + step: 0.01, + precision: 2, + }, + { + label: '澹佸帤(mm)', + prop: 'wallThickness', + el: (props: any, { attrs }: SetupContext) => { + return h(inputNumber, { + ...props, + clearable: true, + ...attrs, + }) + }, + width: '100%', + placeholder: '璇疯緭鍏ュ鍘�', + step: 0.01, + precision: 2, + }, + { + label: '鏉愯川', + prop: 'materialQuality', + el: 'input', + placeholder: '璇疯緭鍏ユ潗璐�(濡�: 304涓嶉攬閽�)', + }, + { + label: '闀垮害(m)', + prop: 'length', + el: (props: any, { attrs }: SetupContext) => { + return h(inputNumber, { + ...props, + clearable: true, + ...attrs, + }) + }, + width: '100%', + placeholder: '璇疯緭鍏ラ暱搴�', + step: 0.1, + precision: 2, + }, + { + label: '鏄惁涓绘敮绠�', + prop: 'isMainBranch', + el: 'select', + options: [], + }, + { + label: '鐢熶骇宸ュ巶', + prop: 'factory', + el: 'input', + placeholder: '璇疯緭鍏ョ敓浜у伐鍘�', + }, + { + label: '璇佷功缂栧彿', + prop: 'certification', + el: 'input', + placeholder: '璇疯緭鍏ヨ瘉涔︾紪鍙�', + }, + { + label: '澶囨敞', + prop: 'remark', + el: 'input', + type: 'textarea', + placeholder: '璇疯緭鍏ュ娉�', + }, + ]) + /** + * 鏍¢獙鏄惁鏈夋暟鎹彉鍖� + */ + const checkIsEqualObject = () => { + const data = { + formData: formData.value, + } + const check = isEqual(initiateData.value, data) + return check + } + const commonGetFormData=()=>{ + const data = { + materialCode: formData.value.materialCode, + materialName: formData.value.materialName, + purchaseType: formData.value.purchaseType, + materialType: formData.value.materialType, + primaryUnit: formData.value.primaryUnit, + standard: formData.value.standard, + outerDiameter: formData.value.outerDiameter, + wallThickness: formData.value.wallThickness, + materialQuality: formData.value.materialQuality, + length: formData.value.length, + isMainBranch: formData.value.isMainBranch, + factory: formData.value.factory, + certification: formData.value.certification, + remark: formData.value.remark, + } + return data; + } + const onClose = (done: () => void) => { + if (visible.value) { + visible.value = false + const data =commonGetFormData(); + ctx.emit('close', data) + } + } + /** + * 纭鏌ヨ + */ + const onConfirmQuery = async () => { + const data =commonGetFormData(); + ctx.emit('confirmQuery', data) + } + /** + * 閲嶇疆鏌ヨ + */ + const onReset = async () => { + formData.value = {} + formData.value.materialCode = '' + formData.value.materialName = '' + formData.value.purchaseType = '' + formData.value.materialType = '' + formData.value.primaryUnit = '' + formData.value.standard = '' + formData.value.outerDiameter = '' + formData.value.wallThickness = '' + formData.value.materialQuality = '' + formData.value.length = '' + formData.value.isMainBranch = '' + formData.value.factory = '' + formData.value.certification = '' + formData.value.remark = '' + //鍚戠埗缁勪欢鍙戦�佽嚜瀹氫箟浜嬩欢 + ctx.emit('restQuery'); + } + + const updateCheckData = () => { + initiateData.value = { + formData: { + ...formData.value, + }, + } + } + const updateFormItemOptions = (propName: string, enumData: any[]) => { + const item = formItems.find((item) => item.prop === propName) + if (item && enumData) { + item.options = enumData.map((item) => ({ + label: item.description, + value: item.value, + })) + } + } + /** + * 閫氱敤鏌ヨ鏋氫妇 + */ + const commonQueryEnumForFrom = async () => { + const materialTypeEnum = await wmsMaterialDrawer.getWmsEnumData({ + EnumName: 'MaterialTypeEnum', + }) + updateFormItemOptions('materialType', materialTypeEnum) + + const purchaseTypeEnum = await wmsMaterialDrawer.getWmsEnumData({ + EnumName: 'PurchaseTypeEnum', + }) + updateFormItemOptions('purchaseType', purchaseTypeEnum) + + const yesOrNoTypeEnum = await wmsMaterialDrawer.getWmsEnumData({ + EnumName: 'YesNoEnum', + }) + updateFormItemOptions('isMainBranch', yesOrNoTypeEnum) + } + commonQueryEnumForFrom() + /** + * 寮圭獥鎵撳紑鑾峰彇璇︽儏 + */ + const onOpen = async () => { + disabled.value = false + updateCheckData() + } + + watch(() => current.value, onOpen) + + return { + formItems, + formData, + visible, + formRef, + onOpen, + onClose, + onConfirmQuery, + onReset, + } +} -- Gitblit v1.9.3