| | |
| | | <template>
|
| | | <view class="tl">
|
| | | <workOrderInfo :orederMessage="{proUserList:[]}" />
|
| | | <workOrderInfo :orederMessage="info" />
|
| | | <div class="tl_title">
|
| | | <div class="tl_title_left">
|
| | | <div class="tl_title_left_x"></div>
|
| | | <span>投料信息</span>
|
| | | <span>{{total == 0 ? '' : total}}{{formList[formList.length - 1].dw ? formList[formList.length - 1].dw : ''}}</span>
|
| | | <!-- <span>{{total == 0 ? '' : total}}{{formList[formList.length - 1].dw ? formList[formList.length - 1].dw : ''}}</span> -->
|
| | | <!-- <span>{{total == 0 ? '' : total}}{{formList[formList.length - 1].dw ? formList[formList.length - 1].dw : ''}}</span> -->
|
| | | </div>
|
| | | <div class="tl_title_right" @click="add">
|
| | | <image src="../../static/gongdan_ic_shoudong@2x.png" class="add-img" mode=""></image>
|
| | |
| | | <div class="tl_list_item" @click="open1(index)">
|
| | | <div class="tl_list_item_label">选择物料</div>
|
| | | <div class="tl_list_item_go" v-if="!item.materialName">
|
| | | <span>点击跳转到物料列表</span> |
| | | <span>点击跳转到物料列表</span>
|
| | | <u-icon name="arrow-right"></u-icon>
|
| | | </div>
|
| | | <div class="tl_list_item_wl" v-else>
|
| | |
| | | </div>
|
| | | </u-swipe-action-item>
|
| | | </u-swipe-action>
|
| | | <view class="" style="height: 88rpx;"></view>
|
| | | <u-safe-bottom></u-safe-bottom>
|
| | | <div class="tl_footer">
|
| | | <button class="tl_footer_submit" v-preventReClick @click="submit">提交</button>
|
| | | </div>
|
| | | <SelectMaterial ref="selectMaterial" @selectAction="getValue" />
|
| | | <!-- <SelectMultipleMaterial ref="selectMultipleMaterial" @selected="getMaterails"/> -->
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import workOrderInfo from '@/components/workOrderInfo.vue'
|
| | | import SelectMaterial from '@/components/selectMaterial.vue'
|
| | | // import SelectMultipleMaterial from '@/components/SelectMultipleMaterial.vue'
|
| | | import {
|
| | | queryById,
|
| | | createMaterial,
|
| | | createMaterialStandard
|
| | | } from '@/util/api/WorkOrderAPI'
|
| | | import {
|
| | | positiveInteger,
|
| | | number
|
| | | } from '@/common/config'
|
| | | export default {
|
| | | components: {
|
| | | workOrderInfo
|
| | | workOrderInfo,
|
| | | SelectMaterial,
|
| | | // SelectMultipleMaterial
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | total: 3,
|
| | | formList: [{
|
| | | dw: 'dasda' |
| | | }],
|
| | | deviceId: '',
|
| | | workorderId: '',
|
| | | // formList: [{
|
| | | // id: Date.now(),
|
| | | // toolingTypeId: '', // 工装类型
|
| | | // toolingTypeName: '', // 工装类型名称
|
| | | // workClothesId: '', // 工装
|
| | | // workClothesName: '', // 工装名称
|
| | | // num: '', // 数量
|
| | | // attribute: '', // 工装属性
|
| | | // attributeType: '', // 工装属性类型
|
| | | // dw: '', // 物料单位
|
| | | // unitAttribute: ''
|
| | | // }],
|
| | | info: {},
|
| | | materialList: [{
|
| | |
|
| | | id: '',
|
| | | materialName: '',
|
| | | materialCode: '',
|
| | | qualityType: '',
|
| | | procedureName: '',
|
| | | locationName: '',
|
| | | batch: '',
|
| | | num: '',
|
| | | unitAttribute: ''
|
| | | }],
|
| | | options: [{
|
| | | text: '删除',
|
| | |
| | | }],
|
| | | };
|
| | | },
|
| | | onLoad(obj) {
|
| | | this.workorderId = obj.id
|
| | | queryById(this.workorderId)
|
| | | .then(res => {
|
| | | if (res.code === 200) {
|
| | | this.info = res.data
|
| | | this.deviceId = res.data.pgmodel.id
|
| | | }
|
| | | })
|
| | | },
|
| | | methods: {
|
| | | open1(index) {
|
| | | // this.$refs.selectMaterial.open({})
|
| | | this.index = index
|
| | | this.$refs.selectMaterial.open({
|
| | | workorderId: this.workorderId,
|
| | | deviceId: this.deviceId
|
| | | })
|
| | | },
|
| | | deleItem(index) {
|
| | | if (this.materialList.length === 1) {
|
| | | uni.$u.toast('至少保留一条投料信息')
|
| | | return
|
| | | }
|
| | | this.materialList.splice(index, 1)
|
| | | },
|
| | | add() {
|
| | | this.total += 1
|
| | | this.materialList.unshift({
|
| | | id: '',
|
| | | materialName: '',
|
| | | materialCode: '',
|
| | | qualityType: '',
|
| | | procedureName: '',
|
| | | locationName: '',
|
| | | batch: '',
|
| | | num: '',
|
| | | unitAttribute: ''
|
| | | })
|
| | | },
|
| | | changeNumber(num, index, unitAttribute) {
|
| | | if (unitAttribute === 0 && num !== '') {
|
| | | if (!positiveInteger.test(num)) {
|
| | | uni.$u.toast({
|
| | | message: '只能输入正整数'
|
| | | })
|
| | | this.materialList[index].num = ''
|
| | | }
|
| | | } else if (unitAttribute === 1 && num !== '') {
|
| | | if (!number.test(num)) {
|
| | | uni.$u.toast({
|
| | | message: '只能输入正整数或小数(最多四位)'
|
| | | })
|
| | | this.materialList[index].num = ''
|
| | | }
|
| | | }
|
| | | if (num <= 0) {
|
| | | uni.$u.toast({
|
| | | message: '投料数量不能小于等于0'
|
| | | })
|
| | | this.materialList[index].num = ''
|
| | | }
|
| | | },
|
| | | getValue(item) {
|
| | | for (let i = 0; i < this.materialList.length; i++) {
|
| | | if (item.id === this.materialList[i].id) {
|
| | | uni.$u.toast({
|
| | | message: '不能重复选择相同物料'
|
| | | })
|
| | | return
|
| | | }
|
| | | }
|
| | | this.materialList[this.index].id = item.id
|
| | | this.materialList[this.index].materialName = item.materialName
|
| | | this.materialList[this.index].num = item.num
|
| | | this.materialList[this.index].batch = item.batch
|
| | | this.materialList[this.index].locationName = item.locationName
|
| | | this.materialList[this.index].materialCode = item.materialCode
|
| | | this.materialList[this.index].procedureName = item.procedureName
|
| | | this.materialList[this.index].qualityType = item.qualityType
|
| | | this.materialList[this.index].unitAttribute = item.unitAttribute
|
| | | },
|
| | | submit() {
|
| | | let temp = this.materialList.findIndex(item => !item.id || !item.num)
|
| | | if (temp != -1) {
|
| | | uni.$u.toast(`请先完善第${temp + 1}条投料信息`)
|
| | | return
|
| | | }
|
| | | let total = this.materialList.reduce((accumulator, currentValue) => accumulator + Number(currentValue.num),
|
| | | 0)
|
| | | console.log(total);
|
| | | if (this.info.bomType != 1 && this.info.hasBom != 1) {
|
| | | if (total > this.info.planNum) {
|
| | | uni.$u.toast(`投料数量不能大于计划数量`)
|
| | | return
|
| | | }
|
| | | }
|
| | | let recordList = this.materialList.map(item => {
|
| | | return {
|
| | | wstockId: item.id,
|
| | | num: item.num
|
| | | }
|
| | | })
|
| | | createMaterialStandard({
|
| | | id: this.workorderId,
|
| | | recordList
|
| | | }).then(res => {
|
| | | if (res.code === 200) {
|
| | | // Toast.success({ message: '投料成功', duration: 2000, forbidClick: true })
|
| | | // setTimeout(() => {
|
| | | // router.go(-1)
|
| | | // }, 2000) |
| | | uni.$u.toast(`投料成功`) |
| | | uni.$emit('addMaterial') |
| | | uni.navigateBack()
|
| | | }
|
| | | })
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | width: 100%;
|
| | | position: fixed;
|
| | | bottom: 0;
|
| | | left: 0;
|
| | | padding: 0 30rpx 68rpx 30rpx;
|
| | | padding: 0 30rpx calc(env(safe-area-inset-bottom) + 20rpx);
|
| | | box-sizing: border-box;
|
| | | z-index: 999;
|
| | | background-color: #fff;
|
| | |
|
| | | .tl_footer_submit {
|
| | | width: 690rpx;
|