You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
482 lines
16 KiB
482 lines
16 KiB
<template>
|
|
<view class="v-pages">
|
|
<view class="v-form v-container" style="padding-bottom: 120rpx;">
|
|
<uni-forms :modelValue="formData" ref="formRef" :label-width="80" :rules="formRules">
|
|
<view class="v-form-item">
|
|
<uni-forms-item label="产品名称" name="processingName" required>
|
|
<input v-model="formData.processingName" placeholder="请输入产品名称" />
|
|
</uni-forms-item>
|
|
<uni-forms-item label="生产数量(公斤)" name="processingProduction" required :label-width="120">
|
|
<input v-model="formData.processingProduction" type="digit" placeholder="请输入生产数量" />
|
|
</uni-forms-item>
|
|
<uni-forms-item label="加工车间" name="workshopId" required>
|
|
<picker @change="WorkShopChange" v-model="formData.workshopId" :value="CurrenWorkShop"
|
|
:range="WorkShopPickerList">
|
|
<view class="uni-input" v-if="WorkShopPickerList[CurrenWorkShop]">
|
|
{{WorkShopPickerList[CurrenWorkShop]}}
|
|
</view>
|
|
<view v-else class="placeholder">请选择加工车间</view>
|
|
<uni-icons type="down" size="14" class="v-icon"></uni-icons>
|
|
</picker>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="加工日期" name="processingTime"> <uni-datetime-picker ref="datetimePicker"
|
|
v-model="formData.processingTime" :clear-icon="false" returnType="timestamp" type="date">
|
|
{{parseTime(formData.processingTime,'{y}-{m}-{d}')||'请选择加工时间'}} <uni-icons type="calendar"></uni-icons>
|
|
</uni-datetime-picker>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="加工项目" name="processingProjection" required>
|
|
<input v-model="formData.processingProjection" placeholder="请输入加工项目" />
|
|
</uni-forms-item>
|
|
<uni-forms-item label="合格证号" name="certificateNumber" required>
|
|
<input v-model="formData.certificateNumber" placeholder="请输入合格证号" />
|
|
</uni-forms-item>
|
|
</view>
|
|
|
|
<view class="v-form-item">
|
|
<uni-forms-item label="认证类型" name="authenticationType">
|
|
<picker @change="AuthenticationTypeChange" :value="CurrenAuthenticationType"
|
|
:range="AuthenticationTypePickerList">
|
|
<view class="uni-input" v-if="AuthenticationTypePickerList[CurrenAuthenticationType]">
|
|
{{AuthenticationTypePickerList[CurrenAuthenticationType]}}
|
|
</view>
|
|
<view v-else class="placeholder">请选择质检结论</view>
|
|
<uni-icons type="down" size="14" class="v-icon"></uni-icons>
|
|
</picker>
|
|
|
|
</uni-forms-item>
|
|
<uni-forms-item label="认证图片" name="authenticationPic">
|
|
<htz-image-upload v-model="imgList" :action="baseUrls" :chooseNum="1" :compress="false"
|
|
:headers="headers" :max="1" :quality="80" :remove="true" :sourceType="['album', 'camera']"
|
|
class="m-img-upload" mediaType="image" @imgDelete="ceshiImgDelete"
|
|
@uploadFail="ceshiUploadFail" @uploadSuccess="ceshiUploadSuccess"></htz-image-upload>
|
|
<uni-easyinput v-model="formData.authenticationPic" class="not-show" placeholder=" " />
|
|
</uni-forms-item>
|
|
</view>
|
|
<view class="v-form-item">
|
|
<uni-forms-item label="质检情况" name="qualityInspection" required>
|
|
<picker @change="QualityInspectionChange" :value="CurrenQualityInspection"
|
|
:range="QualityInspectionPickerList">
|
|
<view class="uni-input" v-if="QualityInspectionPickerList[CurrenQualityInspection]">
|
|
{{QualityInspectionPickerList[CurrenQualityInspection]}}
|
|
</view>
|
|
<view v-else class="placeholder">请选择质检情况</view>
|
|
<uni-icons type="down" size="14" class="v-icon"></uni-icons>
|
|
</picker>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="质检结论" name="qualityResult" required>
|
|
<picker @change="QualityResultChange" :value="CurrenQualityResult"
|
|
:range="QualityResultPickerList">
|
|
<view class="uni-input" v-if="QualityResultPickerList[CurrenQualityResult]">
|
|
{{QualityResultPickerList[CurrenQualityResult]}}
|
|
</view>
|
|
<view v-else class="placeholder">请选择质检结论</view>
|
|
<uni-icons type="down" size="14" class="v-icon"></uni-icons>
|
|
</picker>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="检查结果" name="qualityImage">
|
|
<htz-image-upload v-model="imgList1" :action="baseUrls" :chooseNum="1" :compress="false"
|
|
:headers="headers" :max="1" :quality="80" :remove="true" :sourceType="['album', 'camera']"
|
|
class="m-img-upload" mediaType="image" @imgDelete="ceshiImgDelete"
|
|
@uploadFail="ceshiUploadFail" @uploadSuccess="ceshiUploadSuccess1"></htz-image-upload>
|
|
<uni-easyinput v-model="formData.qualityImage" class="not-show" placeholder=" " />
|
|
</uni-forms-item>
|
|
</view>
|
|
<view class="v-form-item">
|
|
<uni-forms-item label="生产原材料" label-width="100px" name="materialsList" required>
|
|
<view @click="goMaterials()">选择生产原料<uni-icons type="right" size="14"></uni-icons></view>
|
|
</uni-forms-item>
|
|
<view class="v-materials-list no-label" v-if="formData.materialsList.length>0">
|
|
<uni-forms-item required :label-width="0" :name="['materialsList',i,'productUsed']"
|
|
:key="cell.cropperId" :rules="cell.rules" v-for="(cell,i) in formData.materialsList">
|
|
<view class="v-materials-list-item">
|
|
<view class="v-materials-list-box row">
|
|
<view class="col-14">
|
|
<view class="v-materials-name">{{ cell.processingName }}</view>
|
|
<view class="v-materials-info row">
|
|
<view class="item m-r-mini">库存量:<text
|
|
class="number">{{getInventory(cell)}}</text>公斤
|
|
</view>
|
|
<view class="item">批次:<text class="number">{{ cell.batch }}</text></view>
|
|
</view>
|
|
</view>
|
|
<view class="col-10">
|
|
<view class="total-input row">
|
|
<view class="col">
|
|
<input class="border" v-model="formData.materialsList[i].productUsed"
|
|
placeholder="总用量" type="digit" />
|
|
</view>
|
|
<view>公斤</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</uni-forms-item>
|
|
</view>
|
|
</view>
|
|
</uni-forms>
|
|
<view class="fixed fixedBottom v-container">
|
|
<view class="m-t-large v-primary-btn large" @click="submitForm()">保存</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {parseTime} from "@/utils/ruoyi.js";
|
|
|
|
import * as ProductApi from "@/api/traceability/product"
|
|
import * as customApi from "@/api/traceability/custom"
|
|
import mix from '@/utils/mix.js'
|
|
|
|
import {
|
|
getAccessToken
|
|
} from '@/utils/auth';
|
|
import config from '@/config';
|
|
import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue';
|
|
|
|
import {
|
|
getDictDatas,
|
|
DICT_TYPE
|
|
} from '@/utils/dict';
|
|
|
|
export default {
|
|
components: {
|
|
htzImageUpload
|
|
},
|
|
data() {
|
|
return {
|
|
imgList: [],
|
|
imgList1: [],
|
|
baseUrls: config.baseUrl + config.baseApi + '/infra/file/upload',
|
|
headers: {
|
|
Authorization: 'Bearer ' + getAccessToken()
|
|
}, // 设置上传的请求头部
|
|
|
|
|
|
CurrenWorkShop: -1, //当前加工车间
|
|
WorkShopPickerList: [], //加工车间列表
|
|
WorkshopList: [], //加工车间选择列表
|
|
|
|
CurrenQualityInspection: 0, //当前质检情况
|
|
QualityInspectionPickerList: [], //质检情况列表
|
|
QualityInspectionList: [], //质检情况选择列表
|
|
|
|
CurrenQualityResult: 0, //当前质检结论
|
|
QualityResultPickerList: [], //质检结论列表
|
|
QualityResultList: [], //质检结论选择列表
|
|
|
|
CurrenAuthenticationType: 0, //当前认证类型
|
|
AuthenticationTypePickerList: [], //认证类型列表
|
|
AuthenticationTypeList: [], //认证类型选择列表
|
|
formData: {
|
|
id: undefined,
|
|
cropperId: undefined,
|
|
batch: undefined,
|
|
processingName: undefined,
|
|
processingProduction: undefined,
|
|
workshopId: undefined,
|
|
processingTime: undefined,
|
|
processingProjection: undefined,
|
|
authenticationType: 1,
|
|
authenticationPic: undefined,
|
|
qualityInspection: 1,
|
|
qualityResult: 1,
|
|
qualityImage: undefined,
|
|
certificateNumber: undefined,
|
|
husbandryImage: undefined,
|
|
inventoryProduction: undefined,
|
|
traceabilityCode: undefined,
|
|
husbandryNotes: undefined,
|
|
materialsList: []
|
|
},
|
|
// 表单校验
|
|
formRules: {
|
|
processingName: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请输入产品名称'
|
|
}]
|
|
},
|
|
processingProduction: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请输入生产数量'
|
|
}]
|
|
},
|
|
workshopId: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请选择加工车间'
|
|
}]
|
|
},
|
|
processingProjection: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请输入加工项目'
|
|
}]
|
|
},
|
|
qualityInspection: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请选择质检情况'
|
|
}]
|
|
},
|
|
certificateNumber: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请输入合格证号'
|
|
}]
|
|
},
|
|
qualityResult: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请选择质检结论'
|
|
}]
|
|
},
|
|
materialsList: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请选择生产原料'
|
|
}]
|
|
},
|
|
productUsed: [{
|
|
required: true,
|
|
message: '请输入加工总量',
|
|
trigger: 'blur'
|
|
}, ]
|
|
},
|
|
}
|
|
},
|
|
mixins: [mix],
|
|
onLoad(options) {
|
|
if (options.params) {
|
|
this.formData = JSON.parse(decodeURIComponent(options.params));
|
|
this.formData.processingTime = this.formData.processingTime
|
|
this.CurrenWorkShop = this.formData.CurrenWorkShop
|
|
this.CurrenQualityInspection = this.formData.CurrenQualityInspection
|
|
this.CurrenQualityResult = this.formData.CurrenQualityResult
|
|
this.CurrenAuthenticationType = this.formData.CurrenAuthenticationType
|
|
if (this.formData.authenticationPic) {
|
|
this.imgList[0] = this.formData.authenticationPic
|
|
}
|
|
if (this.formData.qualityImage) {
|
|
this.imgList1[0] = this.formData.qualityImage
|
|
}
|
|
} else {
|
|
this.formData = {
|
|
id: undefined,
|
|
cropperId: undefined,
|
|
batch: undefined,
|
|
processingName: undefined,
|
|
processingProduction: undefined,
|
|
workshopId: undefined,
|
|
processingTime: undefined,
|
|
processingProjection: undefined,
|
|
authenticationType: 1,
|
|
authenticationPic: undefined,
|
|
qualityInspection: 1,
|
|
qualityResult: 1,
|
|
qualityImage: undefined,
|
|
certificateNumber: undefined,
|
|
husbandryImage: undefined,
|
|
inventoryProduction: undefined,
|
|
traceabilityCode: undefined,
|
|
husbandryNotes: undefined,
|
|
materialsList: []
|
|
}
|
|
this.formData.processingTime = new Date().valueOf()
|
|
}
|
|
|
|
this.getAllWorkShop()
|
|
this.getQualityInspection()
|
|
this.getQualityResult()
|
|
this.getAuthenticationType()
|
|
},
|
|
onReady() {
|
|
// 设置自定义表单校验规则,必须在节点渲染完毕后执行
|
|
this.$refs.formRef.setRules(this.formRules)
|
|
},
|
|
methods: {
|
|
parseTime(time, pattern) {
|
|
return parseTime(time, pattern);
|
|
},
|
|
/** 提交按钮 */
|
|
async submitForm() {
|
|
// 校验主表
|
|
try {
|
|
await this.$refs['formRef'].validate()
|
|
const data = this.formData
|
|
await ProductApi.createProduct(data)
|
|
uni.showToast({
|
|
title: `保存成功`,
|
|
icon: 'success',
|
|
duration: 2000,
|
|
complete: function() {
|
|
setTimeout(function() {
|
|
uni.redirectTo({
|
|
url: '/pages/index'
|
|
});
|
|
}, 2000);
|
|
}
|
|
})
|
|
} catch (err) {
|
|
console.log("验证未通过",err)
|
|
} finally {}
|
|
},
|
|
|
|
// 获取加工时间
|
|
changeLog(e) {
|
|
this.formData.processingTime = e
|
|
},
|
|
|
|
// 获取销售类型
|
|
getSalesChange(e) {
|
|
this.formData.salesType = e.detail.value[0].value
|
|
},
|
|
|
|
// 获取当前客户Id
|
|
getCustom(e) {
|
|
this.formData.customId = e.detail.value[0].value
|
|
},
|
|
|
|
getCustomChange(e) {
|
|
let value = e.detail.value[0].value
|
|
let newData = this.ClientList.filter((item, index, arr) => {
|
|
return item.id == value
|
|
})
|
|
this.formData.customId = value
|
|
this.formData.customAddress = newData[0].address
|
|
this.formData.contacts = newData[0].logisticsLeader
|
|
this.formData.phone = newData[0].logisticsPhone
|
|
},
|
|
|
|
// 获得加工车间列表
|
|
async getAllWorkShop() {
|
|
try {
|
|
const res = await customApi.getAllProcessingWorkshop()
|
|
let newData = res.data
|
|
this.WorkshopList = newData
|
|
this.WorkShopPickerList = newData.map(item => {
|
|
return item.workshopName
|
|
})
|
|
} finally {}
|
|
},
|
|
|
|
// 选择加工车间
|
|
WorkShopChange(e) {
|
|
this.CurrenWorkShop = e.detail.value
|
|
this.formData.CurrenWorkShop = e.detail.value
|
|
this.formData.workshopId = this.WorkshopList[this.CurrenWorkShop].id
|
|
},
|
|
|
|
//获取质检情况列表
|
|
getQualityInspection() {
|
|
//质检情况 数据字典查询
|
|
let newData = this.getDictDatas(DICT_TYPE.QUALITY_INSPECTION);
|
|
this.QualityInspectionList = newData
|
|
this.QualityInspectionPickerList = newData.map((item) => {
|
|
return item.label
|
|
})
|
|
},
|
|
// 选择质检情况
|
|
QualityInspectionChange(e) {
|
|
this.CurrenQualityInspection = e.detail.value
|
|
this.formData.CurrenQualityInspection = e.detail.value
|
|
this.formData.qualityInspection = this.QualityInspectionList[this.CurrenQualityInspection].value
|
|
},
|
|
|
|
//获取报损类型列表
|
|
getLossType() {
|
|
//报损类型 数据字典查询
|
|
let newData = this.getDictDatas(DICT_TYPE.LOSS_TYPE);
|
|
this.LossTypeList = newData
|
|
this.LossTypePickerList = newData.map((item) => {
|
|
return item.label
|
|
})
|
|
},
|
|
|
|
|
|
//获取质检结论列表
|
|
getQualityResult() {
|
|
//质检结论情况 数据字典查询
|
|
let newData = this.getDictDatas(DICT_TYPE.QUALITY_RESULT);
|
|
this.QualityResultList = newData
|
|
this.QualityResultPickerList = newData.map((item) => {
|
|
return item.label
|
|
})
|
|
},
|
|
|
|
// 选择质检结论
|
|
QualityResultChange(e) {
|
|
this.CurrenQualityResult = e.detail.value
|
|
this.formData.CurrenQualityResult = e.detail.value
|
|
this.formData.qualityResult = this.QualityResultList[this.CurrenQualityResult].value
|
|
},
|
|
|
|
//获取认证类型列表
|
|
getAuthenticationType() {
|
|
//认证类型情况 数据字典查询
|
|
let newData = this.getDictDatas(DICT_TYPE.AUTHENTICATION_TYPE);
|
|
this.AuthenticationTypeList = newData
|
|
this.AuthenticationTypePickerList = newData.map((item) => {
|
|
return item.label
|
|
})
|
|
|
|
},
|
|
|
|
// 选择认证类型
|
|
AuthenticationTypeChange(e) {
|
|
this.CurrenAuthenticationType = e.detail.value
|
|
this.formData.CurrenAuthenticationType = e.detail.value
|
|
this.formData.authenticationType = this.AuthenticationTypeList[this.CurrenAuthenticationType].value
|
|
},
|
|
|
|
// 跳转加工材料
|
|
goMaterials() {
|
|
const data = encodeURIComponent(JSON.stringify(this.formData));
|
|
uni.redirectTo({
|
|
url: '/sunPages/traceability-product/machining/materialsList?params=' + data
|
|
});
|
|
},
|
|
/** 获取库存 */
|
|
getInventory(item) {
|
|
item.productState = false
|
|
if (item.productUsed && !isNaN(item.productUsed)) {
|
|
if ((item.inventoryProduction - item.productUsed) >= 0) {
|
|
return item.inventoryProduction - item.productUsed
|
|
} else {
|
|
item.productState = true
|
|
return item.inventoryProduction
|
|
}
|
|
} else {
|
|
return item.inventoryProduction - 0
|
|
}
|
|
},
|
|
|
|
ceshiUploadSuccess(res) {
|
|
//上传成功
|
|
var _res = JSON.parse(res.data);
|
|
if (_res.code == 0) {
|
|
this.imgList.push(_res.data);
|
|
this.formData.authenticationPic = _res.data;
|
|
}
|
|
},
|
|
ceshiUploadSuccess1(res) {
|
|
//上传成功
|
|
var _res = JSON.parse(res.data);
|
|
if (_res.code == 0) {
|
|
this.imgList1.push(_res.data);
|
|
this.formData.qualityImage = _res.data;
|
|
}
|
|
},
|
|
ceshiImgDelete(e, num) {
|
|
console.log('ceshiImgDelete', e);
|
|
},
|
|
ceshiUploadFail(err) {
|
|
//上传失败
|
|
console.log('err', err);
|
|
},
|
|
|
|
},
|
|
};
|
|
</script> |