|
|
@@ -0,0 +1,370 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button size="small" type="primary" @click="show">
|
|
|
+ {{ title_btn ? $t(title_btn) : $t('新 建') }}
|
|
|
+ </el-button>
|
|
|
+ <el-drawer
|
|
|
+ :title="title_drawer ? $t(title_drawer) : $t(`新建服务物料`)"
|
|
|
+ :visible.sync="dialogFormVisible"
|
|
|
+ direction="rtl"
|
|
|
+ append-to-body
|
|
|
+ :show-close="false"
|
|
|
+ size="700px"
|
|
|
+ @close="onCancel"
|
|
|
+ >
|
|
|
+ <div class="drawer__panel">
|
|
|
+ <el-form
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ ref="form"
|
|
|
+ :label-width="tool.onlyZh('180px')"
|
|
|
+ label-position="right"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ <!-- 物料名称 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('物料名称:')" prop="name">
|
|
|
+ <el-input v-model="form.name" :placeholder="$t('请填写物料名称')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 物料编号 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('物料编号:')" prop="code">
|
|
|
+ <el-input v-model="form.code" :placeholder="$t('请填写物料编号')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- erp品名 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('erp品名:')" prop="erpitemname">
|
|
|
+ <el-input v-model="form.erpitemname" :placeholder="$t('请填写erp品名')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- erp品号 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('erp品号:')" prop="erpitemno">
|
|
|
+ <el-input v-model="form.erpitemno" :placeholder="$t('请填写erp品号')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('牌价:')" prop="marketprice">
|
|
|
+ <el-input v-model="form.marketprice" :placeholder="$t('请填写牌价')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 是否辅助单位 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('辅助单位:')" prop="isauxunit">
|
|
|
+ <el-checkbox v-model="form.isauxunit" :true-label="1" :false-label="0">
|
|
|
+ {{ $t('是否需要辅助单位') }}
|
|
|
+ </el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t(`主单位`)" prop="unit">
|
|
|
+ <el-select
|
|
|
+ style="width: 100%"
|
|
|
+ v-model="form.unit"
|
|
|
+ :placeholder="$t('请选择')"
|
|
|
+ @change="unitChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in unitData"
|
|
|
+ :key="item.unitid"
|
|
|
+ :label="$t(item.unitname)"
|
|
|
+ :value="item.unitid"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 辅助单位 -->
|
|
|
+ <!-- <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('辅助单位:')" prop="auxunit">
|
|
|
+ <el-input v-model="form.auxunit" :placeholder="$t('请填写辅助单位')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col> -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t(`辅助单位`)">
|
|
|
+ <el-select
|
|
|
+ style="width: 100%"
|
|
|
+ v-model="form.auxunit"
|
|
|
+ :disabled="form.isauxunit === 0"
|
|
|
+ :placeholder="$t('请选择')"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in unitGroupData"
|
|
|
+ :key="item.unitgroupid"
|
|
|
+ :label="$t(item.unitgroupname)"
|
|
|
+ :value="item.unitgroupid"
|
|
|
+ >
|
|
|
+ <p style="float: left">{{ item.unitgroupname }}</p>
|
|
|
+ <p style="float: right; color: #8492a6; font-size: 13px">
|
|
|
+ {{ item.conversionrate }}{{ item.unitname }}/{{ item.auxunitname }},{{
|
|
|
+ $t(`换算率`)
|
|
|
+ }}:{{ '1:' + item.conversionrate }}
|
|
|
+ </p>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t(`领域`)" prop="domain">
|
|
|
+ <el-select
|
|
|
+ style="width: 100%"
|
|
|
+ v-model="form.domain"
|
|
|
+ multiple
|
|
|
+ :placeholder="$t('请选择')"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in tradefield"
|
|
|
+ :key="item.value"
|
|
|
+ :label="$t(item.value)"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 起订量 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('起订量:')" prop="start_num">
|
|
|
+ <el-input-number v-model="form.start_num" :min="1" :placeholder="$t('请填写起订量')" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 增量 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('增量:')" prop="increment">
|
|
|
+ <el-input-number v-model="form.increment" :min="1" :placeholder="$t('请填写增量')" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 备注 -->
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('备注:')" prop="remarks">
|
|
|
+ <el-input type="textarea" v-model="form.remarks" :placeholder="$t('请填写备注')"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="20">
|
|
|
+ <el-form-item :label="$t('物料图:')">
|
|
|
+ <uploadFile
|
|
|
+ ref="upload"
|
|
|
+ style="margin-top: 10px"
|
|
|
+ :folderid="folderid"
|
|
|
+ accept=".JPG,.PNG,.jpg,.png"
|
|
|
+ type="image"
|
|
|
+ :bindData="bindData"
|
|
|
+ @onSuccess="uploadSuccess"
|
|
|
+ >
|
|
|
+ </uploadFile>
|
|
|
+ <!-- <previewImage :image="form.attinfos[0]" :deletebtn="true"
|
|
|
+ @onSuccess="clearCover"></previewImage> -->
|
|
|
+ <small style="display: block; margin-top: 20px" class="info"
|
|
|
+ >{{ $t(`注:建议上传图片大小`) }}1024x1024px,{{ $t('大小不超过') }}2M,{{
|
|
|
+ $t('格式为')
|
|
|
+ }}JPG/PNG</small
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="fixed__btn__panel">
|
|
|
+ <el-button size="small" @click="onCancel" class="normal-btn-width">{{ $t('取 消') }}</el-button>
|
|
|
+ <el-button
|
|
|
+ :loading="loading"
|
|
|
+ class="normal-btn-width"
|
|
|
+ size="small"
|
|
|
+ :type="title_btn == '编辑' ? 'warning' : 'primary'"
|
|
|
+ @click="onSubmit"
|
|
|
+ >{{ title_btn == '编辑' ? $t('保 存') : $t('确 定') }}
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import uploadFile from '@/components/upload/preview_upload.vue';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'add',
|
|
|
+ components: { uploadFile },
|
|
|
+ props: { title_btn: String, title_drawer: String, data: Object },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ folderid: JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
|
|
|
+ tradefield: [], // 领域
|
|
|
+ unitData: [], // 主单位
|
|
|
+ unitGroupData: [],
|
|
|
+
|
|
|
+ bindData: {}, // 传递给子组件的图片绑定信息
|
|
|
+ loading: false,
|
|
|
+ dialogFormVisible: false,
|
|
|
+ currentData: {},
|
|
|
+ form: {
|
|
|
+ sc_itemid: 0,
|
|
|
+ code: 'ITEM001', //物料编号
|
|
|
+ name: '测试物料', //物料名称
|
|
|
+ erpitemno: '品号', // 品号
|
|
|
+ erpitemname: '品名', // 品名
|
|
|
+ marketprice: '32', // 牌价
|
|
|
+ isauxunit: 0, //是否启用辅助单位
|
|
|
+ unit: '', //主单位
|
|
|
+ auxunit: '', // 辅助单位
|
|
|
+ domain: '', // 领域
|
|
|
+ start_num: '1', // 起订量
|
|
|
+ increment: '1', // 增量
|
|
|
+ remarks: '', // 备注
|
|
|
+ pic: '', // 图片
|
|
|
+ status: 1,
|
|
|
+ shelf: 0,
|
|
|
+ shefl_time: '2026-05-15 10:00:00',
|
|
|
+ type: '配件',
|
|
|
+ spec: '规格A',
|
|
|
+ brand: '品牌A',
|
|
|
+ category: '分类A',
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ name: [{ required: true, message: this.$t('请填写物料名称'), trigger: 'blur' }],
|
|
|
+ code: [{ required: true, message: this.$t('请填写物料编号'), trigger: 'blur' }],
|
|
|
+ marketprice: [{ required: true, message: this.$t('请填写牌价'), trigger: 'blur' }],
|
|
|
+ unit: [{ required: true, message: this.$t('请选择主单位'), trigger: 'change' }],
|
|
|
+ domain: [{ required: true, message: this.$t('请选择领域'), trigger: 'change' }],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 查询领域
|
|
|
+ async fieldData() {
|
|
|
+ const res = await this.$store.dispatch('optiontypeselect', 'tradefield');
|
|
|
+ console.log('res-----------', res);
|
|
|
+ this.tradefield = res.data;
|
|
|
+ },
|
|
|
+ //初始化
|
|
|
+ show() {
|
|
|
+ this.fieldData();
|
|
|
+ this.queryMain();
|
|
|
+ this.unitlist();
|
|
|
+ this.unitGrouplist();
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ if (this.title_btn == '编辑') {
|
|
|
+ this.form = Object.assign({}, this.form, this.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async unitlist() {
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: '20220922084803',
|
|
|
+ version: 1,
|
|
|
+ nocache: true,
|
|
|
+ content: {
|
|
|
+ pageSize: 1000,
|
|
|
+ where: {
|
|
|
+ condition: '',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.unitData = res.data;
|
|
|
+ },
|
|
|
+ unitChange() {
|
|
|
+ this.unitGrouplist();
|
|
|
+ },
|
|
|
+ async unitGrouplist() {
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: '20220922084503',
|
|
|
+ version: 1,
|
|
|
+ nocache: true,
|
|
|
+ content: {
|
|
|
+ pageSize: 1000,
|
|
|
+ where: {
|
|
|
+ condition: '',
|
|
|
+ unitid: this.form.unitid,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.unitGroupData = res.data;
|
|
|
+ },
|
|
|
+ async queryMain(fn) {
|
|
|
+ // const res = await this.$api.requested({
|
|
|
+ // id: 20220923155302,
|
|
|
+ // content: {
|
|
|
+ // itemid: this.data.itemid,
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // this.form = Object.assign({}, this.form, res.data);
|
|
|
+
|
|
|
+ // this.form.categories = this.form.categories
|
|
|
+ // ? this.form.categories
|
|
|
+ // : this.categoriesList.length > 0
|
|
|
+ // ? this.categoriesList[0].remarks
|
|
|
+ // : '';
|
|
|
+
|
|
|
+ // this.form.domain = this.form.tradefield.map((e) => {
|
|
|
+ // return e.tradefield;
|
|
|
+ // });
|
|
|
+ fn ? fn() : '';
|
|
|
+ },
|
|
|
+ // onSubmit() {
|
|
|
+ // console.log('this.form---------', this.form);
|
|
|
+ // this.$refs['form'].validate(async (valid) => {
|
|
|
+ // if (!valid) return false;
|
|
|
+ // this.loading = true;
|
|
|
+ // const res = await this.$api.requested({
|
|
|
+ // id: '2026051508523606',
|
|
|
+ // content: this.form,
|
|
|
+ // });
|
|
|
+ // this.tool.showMessage(res, () => {
|
|
|
+ // this.$emit('onSuccess');
|
|
|
+ // this.loading = false;
|
|
|
+ // this.$refs['form'].resetFields();
|
|
|
+ // this.dialogFormVisible = false;
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ onSubmit() {
|
|
|
+ console.log('this.form---------', this.form);
|
|
|
+ this.$refs['form'].validate(async (valid) => {
|
|
|
+ if (!valid) return false;
|
|
|
+ this.$store.commit('setLoading', true);
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: 2026051508523606,
|
|
|
+ content: this.form,
|
|
|
+ });
|
|
|
+ this.tool.showMessage(res, () => {
|
|
|
+ this.$store.commit('setLoading', false);
|
|
|
+ this.bindData = {
|
|
|
+ ownertable: 'hs_item',
|
|
|
+ ownerid: res.data.itemid,
|
|
|
+ usetype: 'default',
|
|
|
+ };
|
|
|
+ /* this.setTag(res.data.itemid,res.data.rowindex)*/
|
|
|
+ this.$refs['form'].resetFields();
|
|
|
+ this.$refs['upload'].toUpload();
|
|
|
+ this.$emit('onSuccess');
|
|
|
+ this.refresh();
|
|
|
+ this.dialogFormVisible = false;
|
|
|
+ this.$store.dispatch('changeDetailDrawer', true);
|
|
|
+ // this.$router.push({
|
|
|
+ // path: '/productmagDetail',
|
|
|
+ // query: { id: res.data.itemid, rowindex: res.data.rowindex },
|
|
|
+ // });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onCancel() {
|
|
|
+ this.dialogFormVisible = false;
|
|
|
+ this.$refs['form'].resetFields();
|
|
|
+ },
|
|
|
+ uploadSuccess(res) {
|
|
|
+ this.$emit('onSuccess');
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|