|
@@ -0,0 +1,899 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="product-container">
|
|
|
|
+ <el-form
|
|
|
|
+ :model="productForm"
|
|
|
|
+ :rules="rules"
|
|
|
|
+ ref="productForm"
|
|
|
|
+ label-width="100px"
|
|
|
|
+ >
|
|
|
|
+ <div class="section-title">产品基本信息</div>
|
|
|
|
+ <!-- 使用 el-row 和 el-col 创建三列布局 -->
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
+ <!-- 第一列 -->
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="OA编号">
|
|
|
|
+ <el-input v-model="productForm.dcp_oa_code" placeholder="请输入" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="工程" prop="wr_id">
|
|
|
|
+ <el-select v-model="productForm.wr_id" placeholder="请选择">
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in projectTypes"
|
|
|
|
+ :key="item.wkId"
|
|
|
|
+ :label="item.wkName"
|
|
|
|
+ :value="item.wkId"
|
|
|
|
+ />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="公开价">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="productForm.dcp_price1"
|
|
|
|
+ type="number"
|
|
|
|
+ placeholder="请输入公开价"
|
|
|
|
+ >
|
|
|
|
+ <template slot="append">元</template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="标准价">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="productForm.dcp_price3"
|
|
|
|
+ type="number"
|
|
|
|
+ placeholder="请输入标准价"
|
|
|
|
+ >
|
|
|
|
+ <template slot="append">元</template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+
|
|
|
|
+ <!-- 第二列 -->
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="产品名称">
|
|
|
|
+ <el-input v-model="productForm.dcp_name" placeholder="请输入" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="系统类别" prop="sys_no">
|
|
|
|
+ <el-select v-model="productForm.sys_no" placeholder="请选择">
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in systemTypes"
|
|
|
|
+ :key="item.sysId"
|
|
|
|
+ :label="item.sysName"
|
|
|
|
+ :value="item.sysId"
|
|
|
|
+ />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="销售价">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="productForm.dcp_price2"
|
|
|
|
+ type="number"
|
|
|
|
+ placeholder="请输入销售价"
|
|
|
|
+ >
|
|
|
|
+ <template slot="append">元</template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="大区价">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="productForm.dcp_price4"
|
|
|
|
+ type="number"
|
|
|
|
+ placeholder="请输入大区价"
|
|
|
|
+ >
|
|
|
|
+ <template slot="append">元</template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+
|
|
|
|
+ <!-- 第三列 -->
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="产品应用编号">
|
|
|
|
+ <el-input v-model="productForm.dcp_p_no" placeholder="请输入" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="产品类型">
|
|
|
|
+ <el-input v-model="productForm.dcp_model" placeholder="请输入" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="产品区分代码">
|
|
|
|
+ <el-input v-model="productForm.dcp_diff" placeholder="请输入" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="成本价">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="productForm.dcp_cost_price"
|
|
|
|
+ type="number"
|
|
|
|
+ placeholder="请输入成本价"
|
|
|
|
+ >
|
|
|
|
+ <template slot="append">元</template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <!-- 新增规格表单部分 -->
|
|
|
|
+ <el-collapse v-model="activeCollapse">
|
|
|
|
+ <el-collapse-item title="批量添加功能" name="1">
|
|
|
|
+ <div class="section-title" style="margin: 15px 0 0 0">
|
|
|
|
+ 产品规格及型号
|
|
|
|
+ </div>
|
|
|
|
+ <div class="specs-form">
|
|
|
|
+ <el-form-item label="产品规格:">
|
|
|
|
+ <div class="product-specs">
|
|
|
|
+ <el-tag
|
|
|
|
+ v-for="(item, index) in productSpec"
|
|
|
|
+ :key="`tag_${item.ps_no}_${index}`"
|
|
|
|
+ type="warning"
|
|
|
|
+ effect="plain"
|
|
|
|
+ >
|
|
|
|
+ {{ item.psp_name }}
|
|
|
|
+ </el-tag>
|
|
|
|
+ <el-button
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
+ @click="showSpecDialog"
|
|
|
|
+ ></el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <!-- 修改规格表单部分 -->
|
|
|
|
+ <div class="specs-form">
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-for="(spec, index) in productSpec"
|
|
|
|
+ :key="`spec_${spec.ps_no}_${index}`"
|
|
|
|
+ :label="spec.psp_name + ':'"
|
|
|
|
+ >
|
|
|
|
+ <!-- 长宽比输入处理 -->
|
|
|
|
+ <template v-if="spec.psp_name.includes('长宽比')">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="specForm[spec.ps_no].value1"
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ placeholder="如:19"
|
|
|
|
+ @input="(val) => handleSpecInput(spec.ps_no, 'value1', val)"
|
|
|
|
+ ></el-input>
|
|
|
|
+ <span class="ratio-separator">:</span>
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="specForm[spec.ps_no].value2"
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ placeholder="如:6"
|
|
|
|
+ @input="(val) => handleSpecInput(spec.ps_no, 'value2', val)"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <!-- 其他规格输入处理 -->
|
|
|
|
+ <template v-else>
|
|
|
|
+ <!-- 单选框 -->
|
|
|
|
+ <el-select
|
|
|
|
+ v-if="spec.psp_type === '单选'"
|
|
|
|
+ v-model="specForm[spec.ps_no]"
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ @change="(val) => handleSpecInput(spec.ps_no, null, val)"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="(value, index) in spec.psp_value.split(',')"
|
|
|
|
+ :key="`option_${spec.ps_no}_${index}`"
|
|
|
|
+ :label="value"
|
|
|
|
+ :value="value"
|
|
|
|
+ />
|
|
|
|
+ </el-select>
|
|
|
|
+
|
|
|
|
+ <!-- 多选框 -->
|
|
|
|
+ <el-select
|
|
|
|
+ v-else-if="spec.psp_type === '多选'"
|
|
|
|
+ v-model="specForm[spec.ps_no]"
|
|
|
|
+ multiple
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ @change="(val) => handleSpecInput(spec.ps_no, null, val)"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="(value, index) in spec.psp_value.split(',')"
|
|
|
|
+ :key="`option_${spec.ps_no}_${index}`"
|
|
|
|
+ :label="value"
|
|
|
|
+ :value="value"
|
|
|
|
+ />
|
|
|
|
+ </el-select>
|
|
|
|
+
|
|
|
|
+ <!-- 输入框 -->
|
|
|
|
+ <el-input
|
|
|
|
+ v-else
|
|
|
|
+ v-model="specForm[spec.ps_no]"
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ placeholder="请输入"
|
|
|
|
+ @input="(val) => handleSpecInput(spec.ps_no, null, val)"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </template>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="button-group">
|
|
|
|
+ <el-button type="primary" @click="generateSpec">生成</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </el-collapse-item>
|
|
|
|
+ </el-collapse>
|
|
|
|
+
|
|
|
|
+ <!-- 规格列表表格 -->
|
|
|
|
+ <el-table
|
|
|
|
+ ref="specTable"
|
|
|
|
+ :data="specsList"
|
|
|
|
+ border
|
|
|
|
+ style="width: 100%; margin-top: 20px"
|
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
|
+ >
|
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
|
+ <el-table-column prop="dcp_oa_code" label="OA编号" />
|
|
|
|
+ <el-table-column prop="dcp_p_no" label="产品应用编号" />
|
|
|
|
+ <el-table-column prop="dcp_name" label="产品名称" />
|
|
|
|
+ <el-table-column prop="dcp_model" label="产品型号" />
|
|
|
|
+ <el-table-column label="长宽比">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ {{ scope.row["长宽比"] || "-" }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="刷新率">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ {{ scope.row["刷新率"] || "-" }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="屏幕材质">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ {{ scope.row["屏幕材质"] || "-" }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="150">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <!-- <el-button type="text" size="small" @click="handleAdd(scope.row)"
|
|
|
|
+ >添加</el-button
|
|
|
|
+ > -->
|
|
|
|
+ <el-button
|
|
|
|
+ type="text"
|
|
|
|
+ size="small"
|
|
|
|
+ @click="handleDelete(scope.$index)"
|
|
|
|
+ >删除</el-button
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+
|
|
|
|
+ <div class="button-group">
|
|
|
|
+ <el-button type="primary" @click="batchAdd">保存</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-form>
|
|
|
|
+
|
|
|
|
+ <!-- 添加规格弹窗 -->
|
|
|
|
+ <el-dialog title="添加规格" :visible.sync="specDialogVisible" width="50%">
|
|
|
|
+ <el-form :model="specDialogForm" label-width="120px">
|
|
|
|
+ <el-form-item label="规格编号:">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="specDialogForm.code"
|
|
|
|
+ style="width: 45%"
|
|
|
|
+ placeholder="请输入"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="规格名称:">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="specDialogForm.name"
|
|
|
|
+ style="width: 45%"
|
|
|
|
+ placeholder="请输入"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="规格类型:">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="specDialogForm.type"
|
|
|
|
+ style="width: 45%"
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ >
|
|
|
|
+ <el-option label="输入" value="输入"></el-option>
|
|
|
|
+ <el-option label="单选" value="单选"></el-option>
|
|
|
|
+ <el-option label="复选" value="复选"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="规格值">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="specDialogForm.value"
|
|
|
|
+ style="width: 45%"
|
|
|
|
+ placeholder="请输入"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="产品分类:">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="specDialogForm.category"
|
|
|
|
+ style="width: 45%"
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ >
|
|
|
|
+ <el-option label="全部" value=""></el-option>
|
|
|
|
+ <el-option label="LED" value="LED"></el-option>
|
|
|
|
+ <el-option label="LCD" value="LCD"></el-option>
|
|
|
|
+ <el-option label="DLP" value="DLP"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="specDialogVisible = false">返回</el-button>
|
|
|
|
+ <el-button type="primary" @click="handleSpecSubmit">确认</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <script>
|
|
|
|
+ import {
|
|
|
|
+ getDcSpecList,
|
|
|
|
+ addProduct,
|
|
|
|
+ getInfo,
|
|
|
|
+ editProduct,
|
|
|
|
+ } from "@/api/ProductMent/product";
|
|
|
|
+ import { list } from "@/api/sysCategory/sysCategory";
|
|
|
|
+ import { listWork } from "@/api/worksCategory/worksCategory";
|
|
|
|
+ export default {
|
|
|
|
+ name: "NewProduct",
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ activeCollapse: ["1"],
|
|
|
|
+ activeTab: "basic",
|
|
|
|
+ productForm: {
|
|
|
|
+ wr_id: "",
|
|
|
|
+ sys_no: "",
|
|
|
|
+ dcp_oa_code: "",
|
|
|
|
+ /* productType: "", */
|
|
|
|
+ dcp_name: "",
|
|
|
|
+ dcp_p_no: "",
|
|
|
|
+ dcp_price1: "",
|
|
|
|
+ dcp_price2: "",
|
|
|
|
+ dcp_price3: "",
|
|
|
|
+ dcp_price4: "",
|
|
|
|
+ dcp_cost_price: "",
|
|
|
|
+ dcp_model: "",
|
|
|
|
+ dcp_diff: "",
|
|
|
|
+ },
|
|
|
|
+ // 规格相关数据
|
|
|
|
+ specs: {
|
|
|
|
+ aspectRatio: { width: "", height: "" },
|
|
|
|
+ refreshRate: "",
|
|
|
|
+ resolution: "",
|
|
|
|
+ material: "",
|
|
|
|
+ },
|
|
|
|
+ specsList: [], // 规格列表
|
|
|
|
+ rules: {
|
|
|
|
+ wr_id: [
|
|
|
|
+ { required: true, message: "请选择工程类别", trigger: "change" },
|
|
|
|
+ ],
|
|
|
|
+ sys_no: [
|
|
|
|
+ { required: true, message: "请选择系统类别", trigger: "change" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ // 新增数据
|
|
|
|
+ specForm: {}, // 将改为动态对象
|
|
|
|
+ // 添加一个临时存储生成规格的数组
|
|
|
|
+ generatedSpecs: [],
|
|
|
|
+ specDialogVisible: false,
|
|
|
|
+ specDialogForm: {
|
|
|
|
+ code: "",
|
|
|
|
+ name: "",
|
|
|
|
+ type: "",
|
|
|
|
+ value: "",
|
|
|
|
+ category: "",
|
|
|
|
+ },
|
|
|
|
+ /* 产品规格 */
|
|
|
|
+ productSpec: [],
|
|
|
|
+ /* 系统类别 */
|
|
|
|
+ systemTypes: [],
|
|
|
|
+ /* 工程类别 */
|
|
|
|
+ projectTypes: [],
|
|
|
|
+ /* 存储数据 */
|
|
|
|
+ multipleSelection: [], // 用于存储多选的数据
|
|
|
|
+ selectedSpecs: [], // 存储选中的规格
|
|
|
|
+
|
|
|
|
+ /* id */
|
|
|
|
+ dcp_id: "",
|
|
|
|
+ isEdit: false, // 添加标识是否为编辑模式
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ hasAspectRatio() {
|
|
|
|
+ return this.specs.aspectRatio.width || this.specs.aspectRatio.height;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.dcp_id = this.$route.query.id;
|
|
|
|
+ this.isEdit = !!this.dcp_id; // 根据是否有 ID 判断是编辑还是新增
|
|
|
|
+ this.init();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ /* 列表选中 */
|
|
|
|
+ handleSelectionChange(val) {
|
|
|
|
+ this.multipleSelection = val;
|
|
|
|
+ },
|
|
|
|
+ // 添加规格
|
|
|
|
+ addSpec(type) {
|
|
|
|
+ if (type === "aspectRatio") {
|
|
|
|
+ this.specs.aspectRatio = { width: "19", height: "6" };
|
|
|
|
+ }
|
|
|
|
+ // 其他规格类型处理...
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 移除规格
|
|
|
|
+ removeSpec(type) {
|
|
|
|
+ if (type === "aspectRatio") {
|
|
|
|
+ this.specs.aspectRatio = { width: "", height: "" };
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 添加到列表
|
|
|
|
+ addToList(row) {
|
|
|
|
+ this.specsList.push({
|
|
|
|
+ oaNumber: "12345668",
|
|
|
|
+ dcp_p_no: "DLP11443",
|
|
|
|
+ dcp_name: "DLP高拼屏",
|
|
|
|
+ ...row,
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 从列表中除
|
|
|
|
+ removeFromList(index) {
|
|
|
|
+ this.specsList.splice(index, 1);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 批量添加
|
|
|
|
+ batchAdd() {
|
|
|
|
+ if (this.multipleSelection.length === 0) {
|
|
|
|
+ this.$message.warning("请选择要添加的规格");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const baseData = {
|
|
|
|
+ wr_id: this.productForm.wr_id,
|
|
|
|
+ sys_no: this.productForm.sys_no,
|
|
|
|
+ dcp_oa_code: this.productForm.dcp_oa_code,
|
|
|
|
+ dcp_name: this.productForm.dcp_name,
|
|
|
|
+ dcp_p_no: this.productForm.dcp_p_no,
|
|
|
|
+ dcp_price1: this.productForm.dcp_price1,
|
|
|
|
+ dcp_price2: this.productForm.dcp_price2,
|
|
|
|
+ dcp_price3: this.productForm.dcp_price3,
|
|
|
|
+ dcp_price4: this.productForm.dcp_price4,
|
|
|
|
+ dcp_cost_price: this.productForm.dcp_cost_price,
|
|
|
|
+ dcp_diff: this.productForm.dcp_diff,
|
|
|
|
+ dcp_model: this.productForm.dcp_model,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 如果是编辑模式,将 dcp_id 添加到 baseData 中
|
|
|
|
+ if (this.isEdit) {
|
|
|
|
+ baseData.dcp_id = this.dcp_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const submitData = {
|
|
|
|
+ content: baseData,
|
|
|
|
+ specs: this.productSpec,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 根据模式调用不同的接口
|
|
|
|
+ const request = this.isEdit
|
|
|
|
+ ? editProduct(submitData)
|
|
|
|
+ : addProduct(submitData);
|
|
|
|
+
|
|
|
|
+ request
|
|
|
|
+ .then((res) => {
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
+ this.$message.success(`${this.isEdit ? "编辑" : "添加"}成功`);
|
|
|
|
+ this.$router.push("/cpk/ProductMent/ProductManagement");
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error(
|
|
|
|
+ res.msg || `${this.isEdit ? "编辑" : "添加"}失败`
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ this.$message.error(
|
|
|
|
+ `${this.isEdit ? "编辑" : "添加"}失败:${error.message}`
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 保存所有数据
|
|
|
|
+ saveAll() {
|
|
|
|
+ this.$refs.productForm.validate((valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ // 实现保存逻辑
|
|
|
|
+ console.log("保存数据", this.productForm, this.specsList);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ // 添加新规格
|
|
|
|
+ addNewSpec() {
|
|
|
|
+ // 实现添加新规格的逻辑
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 初始化规格表单
|
|
|
|
+ initSpecForm() {
|
|
|
|
+ const newSpecForm = {};
|
|
|
|
+ this.productSpec.forEach((spec) => {
|
|
|
|
+ if (spec.psp_name.includes("长宽比")) {
|
|
|
|
+ newSpecForm[spec.ps_no] = {
|
|
|
|
+ value1: "",
|
|
|
|
+ value2: "",
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ newSpecForm[spec.ps_no] = spec.psp_type === "多选" ? [] : "";
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.specForm = newSpecForm;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 修改生成规格方法
|
|
|
|
+ generateSpec() {
|
|
|
|
+ if (!this.productForm.dcp_oa_code || !this.productForm.dcp_name) {
|
|
|
|
+ this.$message.warning("请先填写OA编号和产品名称");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 构建规格描述
|
|
|
|
+ const specValues = {};
|
|
|
|
+ this.productSpec.forEach((spec) => {
|
|
|
|
+ // 从 specForm 中获取当前值
|
|
|
|
+ let currentValue = "";
|
|
|
|
+
|
|
|
|
+ if (spec.psp_name.includes("长宽比")) {
|
|
|
|
+ const values = this.specForm[spec.ps_no];
|
|
|
|
+ currentValue =
|
|
|
|
+ values.value1 && values.value2
|
|
|
|
+ ? `${values.value1}:${values.value2}`
|
|
|
|
+ : "";
|
|
|
|
+ } else if (Array.isArray(this.specForm[spec.ps_no])) {
|
|
|
|
+ currentValue = this.specForm[spec.ps_no].join(",");
|
|
|
|
+ } else {
|
|
|
|
+ currentValue = this.specForm[spec.ps_no] || "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新规格的 ps_name
|
|
|
|
+ spec.ps_name = currentValue;
|
|
|
|
+ // 添加到规格值对象
|
|
|
|
+ specValues[spec.psp_name] = currentValue;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 创建新规格对象
|
|
|
|
+ const newSpec = {
|
|
|
|
+ dcp_oa_code: this.productForm.dcp_oa_code,
|
|
|
|
+ dcp_p_no: this.productForm.dcp_p_no,
|
|
|
|
+ dcp_name: this.productForm.dcp_name,
|
|
|
|
+ dcp_model: this.productForm.dcp_model,
|
|
|
|
+ ...specValues,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 清空现有列表并添加新规格
|
|
|
|
+ this.specsList.push(newSpec);
|
|
|
|
+
|
|
|
|
+ // 自动选中新生成的规格
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ if (this.$refs.specTable) {
|
|
|
|
+ this.$refs.specTable.toggleRowSelection(newSpec, true);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.$message.success("规格生成成功");
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 重置规格表
|
|
|
|
+ resetSpecForm() {
|
|
|
|
+ this.initSpecForm();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 处理添加操作
|
|
|
|
+ handleAdd(row) {
|
|
|
|
+ // 实现添加逻辑
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 处理删除操作
|
|
|
|
+ handleDelete(index) {
|
|
|
|
+ this.specsList.splice(index, 1);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ showSpecDialog() {
|
|
|
|
+ this.specDialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handleSpecSubmit() {
|
|
|
|
+ // 创建新的规格对象
|
|
|
|
+ const newSpec = {
|
|
|
|
+ psp_name: this.specDialogForm.name, // 规格名称
|
|
|
|
+ ps_no: this.specDialogForm.code, // 规格编号
|
|
|
|
+ psp_type: this.specDialogForm.type, // 规格类型
|
|
|
|
+ psp_value: this.specDialogForm.value, // 规格值
|
|
|
|
+ psp_category: this.specDialogForm.category, // 产品分类
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 将新规格添加到 productSpec 数组中
|
|
|
|
+ this.productSpec.push(newSpec);
|
|
|
|
+ console.log(this.productSpec);
|
|
|
|
+ // 清空表单
|
|
|
|
+ this.specDialogForm = {
|
|
|
|
+ code: "",
|
|
|
|
+ name: "",
|
|
|
|
+ type: "",
|
|
|
|
+ value: "",
|
|
|
|
+ category: "",
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 关闭弹窗
|
|
|
|
+ this.specDialogVisible = false;
|
|
|
|
+ },
|
|
|
|
+ /* 初始化数据获取 */
|
|
|
|
+ init() {
|
|
|
|
+ // 获取系统类别和产品类别
|
|
|
|
+ Promise.all([
|
|
|
|
+ list(),
|
|
|
|
+ listWork(),
|
|
|
|
+ // 编辑模式下获取产品详情,新增模式下获取规格列表
|
|
|
|
+ this.isEdit ? getInfo(this.dcp_id) : getDcSpecList(),
|
|
|
|
+ ]).then(([sysRes, workRes, specRes]) => {
|
|
|
|
+ this.systemTypes = sysRes.rows;
|
|
|
|
+ this.projectTypes = workRes.rows;
|
|
|
|
+
|
|
|
|
+ if (this.isEdit) {
|
|
|
|
+ // 处理编辑模式数据
|
|
|
|
+ this.handleEditData(specRes.data);
|
|
|
|
+ } else {
|
|
|
|
+ // 处理新增模式数据
|
|
|
|
+ this.productSpec = specRes;
|
|
|
|
+ this.initSpecForm();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 添加处理编辑模式数据的方法
|
|
|
|
+ handleEditData(data) {
|
|
|
|
+ if (!data) return;
|
|
|
|
+
|
|
|
|
+ // 填充基本信息
|
|
|
|
+ const content = data.content;
|
|
|
|
+ this.productForm = {
|
|
|
|
+ ...this.productForm,
|
|
|
|
+ wr_id: content.wr_id,
|
|
|
|
+ sys_no: Number(content.sys_no),
|
|
|
|
+ dcp_model: content.dcp_model,
|
|
|
|
+ dcp_name: content.dcp_name,
|
|
|
|
+ dcp_p_no: content.dcp_p_no,
|
|
|
|
+ dcp_oa_code: content.dcp_oa_code,
|
|
|
|
+ dcp_price1: content.dcp_price1,
|
|
|
|
+ dcp_price2: content.dcp_price2,
|
|
|
|
+ dcp_price3: content.dcp_price3,
|
|
|
|
+ dcp_price4: content.dcp_price4,
|
|
|
|
+ dcp_cost_price: content.dcp_cost_price,
|
|
|
|
+ dcp_diff: content.dcp_diff,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 处理规格数据
|
|
|
|
+ if (data.specs && data.specs.length > 0) {
|
|
|
|
+ // 更新 productSpec,统一使用 ps_no
|
|
|
|
+ this.productSpec = data.specs.map((spec) => ({
|
|
|
|
+ ps_no: spec.ps_no, //用 ps_no
|
|
|
|
+ psp_name: spec.psp_name,
|
|
|
|
+ ps_name: spec.ps_name,
|
|
|
|
+ psp_value: spec.psp_value,
|
|
|
|
+ psp_type: spec.psp_type,
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ // 初始化 specForm
|
|
|
|
+ this.specForm = {};
|
|
|
|
+ data.specs.forEach((spec) => {
|
|
|
|
+ if (spec.psp_name.includes("长宽比")) {
|
|
|
|
+ const [value1, value2] = (spec.ps_name || "").split(":");
|
|
|
|
+ this.specForm[spec.ps_no] = {
|
|
|
|
+ // 使用 ps_no
|
|
|
|
+ value1: value1 || "",
|
|
|
|
+ value2: value2 || "",
|
|
|
|
+ };
|
|
|
|
+ } else if (spec.psp_type === "多选" && spec.ps_name) {
|
|
|
|
+ this.specForm[spec.ps_no] = spec.ps_name.split(","); // 使用 ps_no
|
|
|
|
+ } else {
|
|
|
|
+ this.specForm[spec.ps_no] = spec.ps_name || ""; // 使用 ps_no
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 编辑模式下初始化时不显示列表数据
|
|
|
|
+ this.specsList = [];
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 添加处理规格输入的方法
|
|
|
|
+ handleSpecInput(specNo, field, value) {
|
|
|
|
+ // 找到当前操作的规格对象
|
|
|
|
+ const currentSpec = this.productSpec.find(
|
|
|
|
+ (spec) => spec.ps_no === specNo
|
|
|
|
+ );
|
|
|
|
+ if (!currentSpec) return;
|
|
|
|
+
|
|
|
|
+ if (field) {
|
|
|
|
+ // 处理长宽比输入
|
|
|
|
+ this.$set(this.specForm[specNo], field, value);
|
|
|
|
+ // 立即更新 ps_name
|
|
|
|
+ if (this.specForm[specNo].value1 && this.specForm[specNo].value2) {
|
|
|
|
+ this.$set(
|
|
|
|
+ currentSpec,
|
|
|
|
+ "ps_name",
|
|
|
|
+ `${this.specForm[specNo].value1}:${this.specForm[specNo].value2}`
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 处理其他类型输入
|
|
|
|
+ this.$set(this.specForm, specNo, value);
|
|
|
|
+ // 立即更新 ps_name
|
|
|
|
+ if (Array.isArray(value)) {
|
|
|
|
+ this.$set(currentSpec, "ps_name", value.join(","));
|
|
|
|
+ } else {
|
|
|
|
+ this.$set(currentSpec, "ps_name", value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 强制更新 specsList
|
|
|
|
+ if (this.specsList.length > 0) {
|
|
|
|
+ const updatedSpec = { ...this.specsList[0] };
|
|
|
|
+ updatedSpec[currentSpec.psp_name] = currentSpec.ps_name;
|
|
|
|
+ this.$set(this.specsList, 0, updatedSpec);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 触发视图更新
|
|
|
|
+ this.$forceUpdate();
|
|
|
|
+ },
|
|
|
|
+ /* 获取详细信息 */
|
|
|
|
+ getInfo() {
|
|
|
|
+ getInfo(this.dcp_id).then((res) => {
|
|
|
|
+ if (res.status === 200 && res.data) {
|
|
|
|
+ // 填充基本信息表
|
|
|
|
+ const content = res.data.content;
|
|
|
|
+ this.productForm = {
|
|
|
|
+ ...this.productForm,
|
|
|
|
+ dcp_model: content.dcp_model, // 产品型号
|
|
|
|
+ dcp_name: content.dcp_name, // 产品名称
|
|
|
|
+ dcp_p_no: content.dcp_p_no, // 产品编号
|
|
|
|
+ dcp_oa_code: content.dcp_oa_code, // OA编号
|
|
|
|
+ dcp_price1: content.dcp_price1, // 公开价
|
|
|
|
+ dcp_price2: content.dcp_price2, // 销售价
|
|
|
|
+ dcp_price3: content.dcp_price3, // 标准价
|
|
|
|
+ dcp_price4: content.dcp_price4, // 大区价
|
|
|
|
+ dcp_cost_price: content.dcp_cost_price, // 成本价
|
|
|
|
+ dcp_diff: content.dcp_diff, // 产品区分代码
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 处理规格信息
|
|
|
|
+ if (res.data.specs && res.data.specs.length > 0) {
|
|
|
|
+ const specs = res.data.specs[0]; // 获取第一个规格信息
|
|
|
|
+
|
|
|
|
+ // 更新规格表单
|
|
|
|
+ if (this.specForm[specs.ps_no]) {
|
|
|
|
+ // 处理长宽比等特殊规格
|
|
|
|
+ if (specs.psp_name.includes("长宽比")) {
|
|
|
|
+ const [value1, value2] = specs.ps_name.split(":");
|
|
|
|
+ this.specForm[specs.ps_no] = {
|
|
|
|
+ value1: value1,
|
|
|
|
+ value2: value2,
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ // 处理多选规格
|
|
|
|
+ else if (specs.psp_type === "多选" && specs.ps_name) {
|
|
|
|
+ this.specForm[specs.ps_no] = specs.ps_name.split(",");
|
|
|
|
+ }
|
|
|
|
+ // 处理普通规格
|
|
|
|
+ else {
|
|
|
|
+ this.specForm[specs.ps_no] = specs.ps_name;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新产品规格数
|
|
|
|
+ const existingSpecIndex = this.productSpec.findIndex(
|
|
|
|
+ (spec) => spec.ps_no === specs.ps_no
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (existingSpecIndex !== -1) {
|
|
|
|
+ // 更新已存在的规格
|
|
|
|
+ this.productSpec[existingSpecIndex] = {
|
|
|
|
+ ...this.productSpec[existingSpecIndex],
|
|
|
|
+ ps_name: specs.ps_name,
|
|
|
|
+ psp_value: specs.psp_value,
|
|
|
|
+ ps_no: specs.ps_no,
|
|
|
|
+ psp_name: specs.psp_name,
|
|
|
|
+ psp_type: specs.psp_type,
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ // 添加新规格
|
|
|
|
+ this.productSpec.push({
|
|
|
|
+ ps_name: specs.ps_name,
|
|
|
|
+ psp_value: specs.psp_value,
|
|
|
|
+ ps_no: specs.ps_no,
|
|
|
|
+ psp_name: specs.psp_name,
|
|
|
|
+ psp_type: specs.psp_type,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 初始化规格表单
|
|
|
|
+ this.initSpecForm();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ </script>
|
|
|
|
+
|
|
|
|
+ <style scoped>
|
|
|
|
+ .product-container {
|
|
|
|
+ padding: 20px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .specs-container {
|
|
|
|
+ margin-top: 20px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .specs-header {
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .button-container {
|
|
|
|
+ margin-top: 20px;
|
|
|
|
+ text-align: center;
|
|
|
|
+ }
|
|
|
|
+ .specs-form {
|
|
|
|
+ padding: 20px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .specs-header {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+ align-items: center;
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .ratio-separator {
|
|
|
|
+ margin: 0 10px;
|
|
|
|
+ font-size: 20px;
|
|
|
|
+ color: #909399;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .operation-buttons {
|
|
|
|
+ margin-left: 10px;
|
|
|
|
+ display: inline-block;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .button-group {
|
|
|
|
+ margin-top: 20px;
|
|
|
|
+ text-align: center;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .spec-tags {
|
|
|
|
+ margin-bottom: 15px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* .product-specs {
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
+ } */
|
|
|
|
+
|
|
|
|
+ .product-specs .el-tag {
|
|
|
|
+ margin-right: 10px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .product-specs .el-button {
|
|
|
|
+ padding: 0 4px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* 调整折叠面板式 */
|
|
|
|
+ ::v-deep .el-collapse-item__header {
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ padding-left: 10px;
|
|
|
|
+ background-color: #f5f7fa;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-collapse-item__content {
|
|
|
|
+ padding: 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* 添加标题样式 */
|
|
|
|
+ .section-title {
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ color: #606266;
|
|
|
|
+ line-height: 25px;
|
|
|
|
+ padding-left: 8px;
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* 修改表单项样式以适应三列布局 */
|
|
|
|
+ ::v-deep .el-form-item {
|
|
|
|
+ margin-bottom: 18px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-input,
|
|
|
|
+ ::v-deep .el-select {
|
|
|
|
+ width: 100%; /* 使输入框和选择框占满列宽 */
|
|
|
|
+ }
|
|
|
|
+ </style>
|