| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464 |
- <template>
- <!-- :close-on-click-modal="false" -->
- <ele-modal width="80vw" :visible.sync="visible" custom-class="ele-dialog-form" :title="title" :maxable="true">
- <div class="form-wrapper">
- <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="formbox">
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="产品名称:" prop="productName">
- <el-input @click.native="handleAdd" placeholder="请选择物料" v-model="form.productName" size="mini"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="编码:" prop="productCode">
- <el-input placeholder="" size="mini" disabled v-model="form.productCode"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="牌号:" prop="brandNum">
- <el-input placeholder="" size="mini" disabled v-model="form.brandNum"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="型号:" prop="modelType">
- <el-input placeholder="" size="mini" disabled v-model="form.modelType"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="规格:" prop="specification">
- <el-input placeholder="" size="mini" disabled v-model="form.specification"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="计划信息"> </headerTitle>
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="加工方式:" prop="produceType">
- <el-select v-model="form.produceType" style="width: 100%" @change="changeProduceType" size="mini">
- <el-option v-for="item of producedList" :key="item.code" :label="item.name"
- :value="item.code"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="BOM版本:" prop="bomCategoryId" v-if="clientEnvironmentId != 4">
- <el-select v-model="form.bomCategoryId" style="width: 100%" @change="changeBomId" size="mini">
- <el-option v-for="item of bomVersionList" :key="item.id"
- :label="item.name + '(V' + item.versions + '.0)'" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="工艺路线:" prop="produceRoutingId" v-if="clientEnvironmentId !== 4">
- <el-select v-model="form.produceRoutingId" style="width: 100%" @change="changeRoute" size="mini">
- <el-option v-for="item of routingList" :key="item.id" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="工艺路线:" prop="produceRoutingId" v-if="clientEnvironmentId == 4">
- <el-input v-model="form.produceRoutingName" style="width: 100%" readonly></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="生产数量:" prop="requiredFormingNum">
- <el-input v-model.number="form.requiredFormingNum" size="mini" oninput="value=value.replace(/[^\d]/g,'')"
- style="width: 100%" placeholder="输入数量">
- <template slot="append">{{ form.measuringUnit }} </template>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="批次号:" prop="batchNo">
- <el-input v-model="form.batchNo" size="mini" style="width: 100%" placeholder="输入批次号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="要求完成日期:" label-width="110px" prop="reqMoldTime">
- <el-date-picker style="width: 100%" size="mini" v-model="form.reqMoldTime" :pickerOptions="{
- disabledDate: (time) =>
- time.getTime() <
- new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
- </el-date-picker>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="计划开始日期:" label-width="110px" prop="startTime">
- <el-date-picker style="width: 100%" size="mini" v-model="form.startTime" :pickerOptions="{
- disabledDate: (time) =>
- time.getTime() <
- new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="计划结束日期:" label-width="110px" prop="endTime">
- <el-date-picker style="width: 100%" size="mini" v-model="form.endTime" :pickerOptions="{
- disabledDate: (time) =>
- time.getTime() <
- new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
- </el-date-picker>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <!-- 选择产品 -->
- <EquipmentDialog ref="equipmentRefs" @choose="confirmChoose" :selectList="[]">
- </EquipmentDialog>
- </div>
- <template v-slot:footer>
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="save" :loading="loading">
- 确定
- </el-button>
- </template>
- </ele-modal>
- </template>
- <script>
- import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
- import { getCode } from '@/api/codeManagement';
- import {
- bomRoutingList,
- bomListByPlan,
- saveSaleToPlan,
- temporarilyUpdate
- } from '@/api/saleOrder';
- export default {
- components: {
- EquipmentDialog
- },
- props: {
- factoryType: {
- type: Number,
- default: 3
- },
- factoryObj: {
- type: Object,
- default: () => { }
- }
- },
- watch: {
- factoryObj: {
- immediate: true,
- deep: true,
- handler(val) {
- // this.type = val;
- this.title = !val.id ? '新增临时计划' : '编辑临时计划';
- // this.form = this.factoryObj;
- this.form = val;
- // 修改
- this.$nextTick(() => {
- if (val.id) {
- this.bomListVersion();
- if (val.bomCategoryId) {
- this.getPlanRouting();
- }
- }
- });
- }
- }
- },
- computed: {
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- },
- data() {
- return {
- visible: false,
- title: '',
- type: 3,
- loading: false,
- form: {
- timeDimensionPlanType: 3,
- categoryId: '',
- productName: '',
- planType: 1,
- id: '',
- produceType: 2,
- bomCategoryId: '',
- produceRoutingId: '',
- requiredFormingNum: ''
- },
- bomVersionList: [],
- routingList: [],
- rules: {
- productName: [
- { required: true, message: '请选择名称', trigger: 'change' }
- ],
- bomCategoryId: [
- { required: true, message: '请选择BOM版本', trigger: 'blur' }
- ],
- produceType: [
- { required: true, message: '请选择工艺路线', trigger: 'blur' }
- ],
- produceRoutingId: [
- { required: true, message: '请选择工艺路线', trigger: 'blur' }
- ],
- reqMoldTime: [
- { required: true, message: '请选择要求完成日期', trigger: 'blur' }
- ],
- requiredFormingNum: [
- { required: true, message: '请输入生产数量', trigger: 'blur' }
- ]
- },
- producedList: [
- { code: 2, name: '加工(MBOM)' },
- { code: 3, name: '装配(ABOM)' }
- ]
- };
- },
- computed: {
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- }
- },
- methods: {
- open() {
- this.visible = true;
- console.log(this.clientEnvironmentId, '999999999');
- //this.clientEnvironmentId 环境判断 宝悦环境
- if (this.clientEnvironmentId == 4) {
- this.getPlanRoutingNew();
- }
- // this.getPlanRoutingNew();
- },
- handleAdd() {
- this.$refs.equipmentRefs.open();
- },
- confirmChoose(list) {
- console.log(list, '6666666666666666');
- if (this.clientEnvironmentId == '4') {
- let data = {};
- if (list[0].name.includes('板材')) {
- data = {
- id: '1856970794952372226',
- name: '板材',
- produceVersionName: '板材'
- };
- } else {
- data = {
- id: '1857313733642596353',
- name: '砌块',
- produceVersionName: '砌块'
- };
- }
- this.$set(this.form, 'produceRoutingName', data.name);
- this.$set(this.form, 'produceRoutingId', data.id);
- this.$set(this.form, 'produceVersionName', data.produceVersionName);
- }
- this.$set(this.form, 'categoryId', list[0].id);
- this.$set(this.form, 'productName', list[0].name);
- this.$set(this.form, 'productCode', list[0].code);
- this.$set(this.form, 'specification', list[0].specification);
- this.$set(this.form, 'brandNum', list[0].brandNum);
- this.$set(this.form, 'modelType', list[0].modelType);
- this.$set(this.form, 'measuringUnit', list[0].measuringUnit);
- this.bomListVersion();
- },
- handleDeleteItem(index) {
- this.form.salesOrders.splice(index, 1);
- },
- async getPlanCode() {
- this.loading = true;
- try {
- const code = await getCode('product_code');
- this.$set(this.form, 'code', code);
- } catch (err) { }
- },
- initForm() {
- this.form = {
- timeDimensionPlanType: 3,
- categoryId: '',
- productName: '',
- planType: 1,
- id: '',
- produceType: 2,
- bomCategoryId: '',
- produceRoutingId: '',
- requiredFormingNum: ''
- };
- },
- save() {
- this.$refs.form.validate(async (valid) => {
- if (!valid) {
- return false;
- }
- //
- console.log(this.form.id, 'this.form.idthis.form.idthis.form.idthis.form.id');
- if (!this.form.id) {
- this.form.timeDimensionPlanType = this.type;
- await this.getPlanCode();
- this.loading = true;
- saveSaleToPlan(this.form)
- .then((res) => {
- this.$message.success('新增成功!');
- this.visible = false;
- this.initForm();
- this.$emit('close', true);
- })
- .finally(() => {
- this.loading = false;
- });
- } else {
- this.loading = true;
- temporarilyUpdate(this.form)
- .then((res) => {
- this.$message.success('修改成功!');
- this.visible = false;
- this.initForm();
- this.$emit('close', true);
- })
- .finally(() => {
- this.loading = false;
- });
- }
- });
- },
- bomListVersion() {
- let param = {
- bomType: this.form.produceType,
- categoryId: this.form.categoryId
- };
- bomListByPlan(param).then((res) => {
- this.bomVersionList = res || [];
- });
- },
- // 工艺路线
- getPlanRouting() {
- bomRoutingList(this.form.bomCategoryId).then((res) => {
- this.routingList = res || [];
- });
- },
- // 宝悦 工艺路线
- getPlanRoutingNew() {
- // bomRoutingList(this.form.bomCategoryId).then((res) => {
- // this.routingList = res || []
- // })
- },
- changeProduceType() {
- this.form.bomCategoryId = '';
- this.form['bomCategoryName'] = '';
- this.form['bomCategoryVersions'] = '';
- this.bomVersionList = [];
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- this.bomListVersion();
- },
- changeBomId() {
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- this.bomVersionList.forEach((f) => {
- if (f.id == this.form.bomCategoryId) {
- this.$set(this.form, 'bomCategoryName', f.name);
- this.$set(this.form, 'bomCategoryVersions', f.versions);
- }
- });
- this.getPlanRouting();
- },
- changeRoute() {
- console.log(this.routingList, this.form.produceRoutingId);
- this.$forceUpdate()
- this.routingList.forEach((f) => {
- if (f.id == this.form.produceRoutingId) {
- this.$set(this.form, 'produceRoutingId', f.id);
- this.$set(this.form, 'produceRoutingName', f.name);
- this.$set(this.form, 'produceVersionName', f.version);
- }
- });
- },
- cancel() {
- console.log('取消');
- this.visible = false;
- this.$emit('close');
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .el-form-item {
- margin-bottom: 14px !important;
- }
- </style>
|