|
|
@@ -0,0 +1,177 @@
|
|
|
+<!--
|
|
|
+ * @Author: WangXingCheng wangxingcheng@dashoo.cn
|
|
|
+ * @Date: 2023-01-10 12:53:25
|
|
|
+ * @LastEditors: wanglj
|
|
|
+ * @LastEditTime: 2023-01-10 18:07:31
|
|
|
+ * @Description: file content
|
|
|
+ * @FilePath: /opms_frontend/src/views/base/product/components/ProductEdit.vue
|
|
|
+-->
|
|
|
+
|
|
|
+<template>
|
|
|
+ <el-dialog append-to-body :title="title" :visible.sync="dialogFormVisible" @close="handleClose">
|
|
|
+ <el-form ref="editForm" :disabled="formDisavled" :model="editForm" :rules="rules">
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="产品编码" prop="prodCode">
|
|
|
+ <el-input v-model="editForm.prodCode" placeholder="请输入产品编码" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="产品名称" prop="prodName">
|
|
|
+ <el-input v-model="editForm.prodName" placeholder="请输入产品名称" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="产品分类" prop="prodClass">
|
|
|
+ <el-select v-model="editForm.prodClass" placeholder="请选择产品分类" style="width: 100%">
|
|
|
+ <el-option v-for="item in classOptions" :key="item.value" :label="item.value" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="成交价" prop="distPrice">
|
|
|
+ <currency v-model.trim="editForm.distPrice" :value="1" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="经销商价" prop="guidPrice">
|
|
|
+ <currency v-model.trim="editForm.guidPrice" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="签约代理价" prop="agentPrice">
|
|
|
+ <currency v-model.trim="editForm.agentPrice" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="市场报价" prop="marketPrice">
|
|
|
+ <currency v-model.trim="editForm.marketPrice" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-form-item label="产品说明" prop="remark">
|
|
|
+ <el-input
|
|
|
+ v-model="editForm.remark"
|
|
|
+ maxlength="500"
|
|
|
+ placeholder="请输入产品说明"
|
|
|
+ resize="none"
|
|
|
+ :rows="5"
|
|
|
+ show-word-limit
|
|
|
+ type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button v-show="!formDisavled" type="primary" @click="save">确 定</el-button>
|
|
|
+ <el-button @click="dialogFormVisible = false">取消</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import to from 'await-to-js'
|
|
|
+ import productApi from '@/api/base/product'
|
|
|
+ import currency from '@/components/currency'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ //name: 'UserEdit',
|
|
|
+ components: {
|
|
|
+ currency,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ title: '',
|
|
|
+ dialogFormVisible: false,
|
|
|
+ formDisavled: false, //表单禁用
|
|
|
+ editForm: {
|
|
|
+ prodCode: '', //产品编码
|
|
|
+ prodName: '', //产品名称
|
|
|
+ prodClass: '', //产品类别
|
|
|
+ guidPrice: '', //建议成交价
|
|
|
+ distPrice: '', //经销商价格
|
|
|
+ custStatus: '', //代理商价格
|
|
|
+ agentPrice: '', //目标价格
|
|
|
+ marketPrice: '', //市场价
|
|
|
+ remark: '', //产品说明
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ prodCode: [{ required: true, trigger: 'blur', message: '请输入产品编码' }],
|
|
|
+ prodName: [{ required: true, trigger: 'blur', message: '请输入产品名称' }],
|
|
|
+ prodClass: [{ required: true, trigger: 'blur', message: '请输入产品分类' }],
|
|
|
+ guidPrice: [{ required: true, trigger: 'blur', message: '请输入建议成交价' }],
|
|
|
+ distPrice: [{ required: true, trigger: 'blur', message: '请输入经销商价' }],
|
|
|
+ },
|
|
|
+ classOptions: [], //产品分类
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getOptions()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init(id, disabled = false) {
|
|
|
+ this.formDisavled = disabled
|
|
|
+ if (!id) {
|
|
|
+ this.title = '新增产品信息'
|
|
|
+ } else {
|
|
|
+ this.title = '编辑产品信息'
|
|
|
+ let params = { id }
|
|
|
+ console.log('params----', params)
|
|
|
+ const [err, res] = await to(productApi.getDetails(params))
|
|
|
+ console.log(res)
|
|
|
+ if (err) return
|
|
|
+ if (res.data) {
|
|
|
+ this.editForm = res.data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ },
|
|
|
+ getOptions() {
|
|
|
+ Promise.all([this.getDicts('product_type')])
|
|
|
+ .then(([productType]) => {
|
|
|
+ this.classOptions = productType.data.values || []
|
|
|
+ })
|
|
|
+ .catch((err) => console.log(err))
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.editForm = {
|
|
|
+ prodCode: '', //产品编码
|
|
|
+ prodName: '', //产品名称
|
|
|
+ prodClass: '', //产品类别
|
|
|
+ guidPrice: '', //建议成交价
|
|
|
+ distPrice: '', //经销商价格
|
|
|
+ custStatus: '', //代理商价格
|
|
|
+ agentPrice: '', //目标价格
|
|
|
+ marketPrice: '', //市场价
|
|
|
+ remark: '', //产品说明
|
|
|
+ }
|
|
|
+ this.$refs.editForm.resetFields()
|
|
|
+ },
|
|
|
+
|
|
|
+ save() {
|
|
|
+ this.$refs['editForm'].validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.editForm.id) {
|
|
|
+ this.editForm.guidPrice = parseFloat(this.editForm.guidPrice).toFixed(2)
|
|
|
+ this.editForm.distPrice = parseFloat(this.editForm.distPrice).toFixed(2)
|
|
|
+ this.editForm.agentPrice = parseFloat(this.editForm.agentPrice).toFixed(2)
|
|
|
+ this.editForm.marketPrice = parseFloat(this.editForm.marketPrice).toFixed(2)
|
|
|
+ const { msg } = await productApi.doEdit(this.editForm)
|
|
|
+ this.$baseMessage(msg, 'success', 'vab-hey-message-success')
|
|
|
+ } else {
|
|
|
+ this.editForm.guidPrice = parseFloat(this.editForm.guidPrice).toFixed(2)
|
|
|
+ const { msg } = await productApi.doAdd(this.editForm)
|
|
|
+ this.$baseMessage(msg, 'success', 'vab-hey-message-success')
|
|
|
+ }
|
|
|
+ this.$emit('fetch-data')
|
|
|
+ this.editVisible = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|