From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- pages/wareHouse/packing/form.vue | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 224 insertions(+), 0 deletions(-) diff --git a/pages/wareHouse/packing/form.vue b/pages/wareHouse/packing/form.vue new file mode 100644 index 0000000..7e8d302 --- /dev/null +++ b/pages/wareHouse/packing/form.vue @@ -0,0 +1,224 @@ +<template> + <view class="wrap"> + <u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left"> + <u-form-item label="绠卞彿" prop="no" label-width="180" :required="true"> + <input v-model="model.no" placeholder="璇锋壂绠卞彿" :disabled="true"></input> + </u-form-item> + <u-form-item label="鐗╂枡缂栫爜" prop="cusMaterialCode" label-width="180" > + <input v-model="model.cusMaterialCode" placeholder="璇锋壂鐗╂枡缂栫爜" :disabled="true"></input> + </u-form-item> + <u-form-item label="鍖呰灏哄" prop="packSize" label-width="180" > + <picker @change="bindPackSizeChange($event,packSizeList)" :value="packSizeIndex" :range="packSizeList" + range-key="value"> + <view> + <text>{{packSizeIndex==null ? "璇烽�夋嫨":packSizeList[packSizeIndex].value}}</text> + </view> + </picker> + </u-form-item> + <u-form-item label="鍖呮潗" prop="packMaterial" label-width="180" > + <picker @change="bindPackMaterialChange($event,packMaterialList)" :value="packMaterialIndex" + :range="packMaterialList" range-key="value"> + <view> + <text>{{packMaterialIndex==null ? "璇烽�夋嫨":packMaterialList[packMaterialIndex].value}}</text> + </view> + </picker> + </u-form-item> + <u-form-item label="鍖呰閲嶉噺" prop="packWeight" label-width="180" > + <input placeholder="璇疯緭鍏ュ寘瑁呴噸閲�" v-model="model.packWeight" type="digit" :disabled="true"></input> + </u-form-item> + </u-form> + <view class="form-footer"> + <u-button class="btn" type="primary" @click="submit">鎻愪氦</u-button> + <u-button class="btn" type="default" @click="cancel">娓呯┖鎵爜</u-button> + </view> + <scan></scan> + </view> +</template> + +<script> + import scan from "@/components/scan/scan.vue"; + export default { + components: { + scan + }, + data() { + return { + type: '', + model: { + id: 0, + // no: 'BZ0000000011', + // cusMaterialCode: '88.118.1/A0306595', + no: '', + cusMaterialCode: '', + packWeight: '', + packSize: '', + packMaterial: '' + }, + rules: { + no: [{ + required: true, + message: '缂栧彿涓嶈兘涓虹┖', + trigger: 'blur' + }], + packWeight: [{ + required: true, + message: '鍖呰閲嶉噺涓嶈兘涓虹┖', + trigger: 'blur' + }], + packSize: [{ + required: true, + message: '鍖呰灏哄涓嶈兘涓虹┖', + trigger: 'blur' + }], + packMaterial: [{ + required: true, + message: '鍖呮潗涓嶈兘涓虹┖', + trigger: 'blur' + }], + }, + packMaterialList: [], + packMaterialIndex: null, + packSizeList: [], + packSizeIndex: null, + packWeightList: [], + } + }, + onLoad() { + this.type = 'add' + this.model = {} + }, + onShow() { + + let that = this + + uni.$off('scan') // 姣忔杩涙潵鍏� 绉婚櫎鍏ㄥ眬鑷畾涔変簨浠剁洃鍚櫒 + uni.$on('scan', function(data) { + console.log('onscan'); + //鎵爜鎴愬姛鍚庣殑鍥炶皟锛屼綘鍙互鍐欒嚜宸辩殑閫昏緫浠g爜鍦ㄨ繖閲� + console.log('鎵爜缁撴灉锛�', data.code); + if (that.model.no == "undefined" || that.model.no == "" || that.model.no == undefined) { + that.model.no = data.code + } else { + that.model.cusMaterialCode = data.code + } + that.$forceUpdate(); + + }) + }, + onNavigationBarButtonTap(e) { + uni.scanCode({ + success: res => { + try { + const result = JSON.parse(res.result) + + } catch (e) {} + } + }); + }, + onReady() { + // this.$refs.uForm.setRules(this.rules); + + let that = this + that.$u.api.pigxPacking.packHeadBasicInfoList().then(res => { + + let packSizeList = res.data.packSizeWeightList + let packMaterialList = res.data.packMaterialList + + that.packWeightList = packSizeList + + if (packSizeList.length > 0) { + packSizeList.map((item, index) => { + + let packSize = { + lable: item.packSize, + value: item.packSize + } + that.packSizeList.push(packSize) + }); + } + + packMaterialList.map((item, index) => { + let packMaterial = { + lable: item, + value: item + } + that.packMaterialList.push(packMaterial) + }); + }); + + + }, + methods: { + submit() { + + + if (JSON.stringify(this.model) == "{}") { + this.$u.toast('璇峰~鍐欏繀濉俊鎭�') + return + } + + this.$refs.uForm.validate(async valid => { + if (valid) { + + await this.$u.api.pigxPacking.addObj(this.model) + setTimeout(() => { + uni.showModal({ + title: '鎻愮ず', + content: '娣诲姞鎴愬姛', + showCancel: false, + success: function() { + uni.setStorageSync('refreshList', true); + uni.navigateTo({ + url: '/pages/wareHouse/packing/index' + }) + } + }) + }, 200) + } else { + this.$u.toast('鎮ㄥ~鍐欑殑淇℃伅鏈夎锛岃鏍规嵁鎻愮ず淇銆�') + } + }); + }, + cancel() { + this.model.no = "" + this.model.cusMaterialCode = "" + this.$forceUpdate(); + }, + //鍖呰澶у皬閫夋嫨 + bindPackSizeChange(e, storage) { + + if (storage.length <= 0) { + this.packSizeIndex = null + return + } + this.packSizeIndex = e.target.value + this.model.packSize = storage[this.packSizeIndex].value + + let list = this.packWeightList.filter(item => item.packSize = storage[this.packSizeIndex].value) + if (list.length > 0) { + this.model.packWeight = list[0].packWeight + } + }, + //鍖呮潗閫夋嫨 + bindPackMaterialChange(e, storage) { + + if (storage.length <= 0) { + this.packMaterialIndex = null + return + } + this.packMaterialIndex = e.target.value + this.model.packMaterial = storage[this.packMaterialIndex].value + }, + + } + } +</script> +<style lang="scss" scoped> + .uni-input-placeholder { + font-size: 12px; + } + + uni-input{font-size: 12px;} + + +</style> -- Gitblit v1.9.3