Explorar o código

添加新的文档及模块接口

yangg hai 6 meses
pai
achega
03a1aac12e

+ 10 - 12
ui/src/api/document.js

@@ -3,7 +3,7 @@ import request from '@/utils/request'
 /* 无data  文档编辑器中的文档及模版列表 */
 export function pageDocument(data) {
   return request({
-    url: '/document/pageDocument',
+    url: '/document/list',
     method: 'post',
     data
   })
@@ -41,7 +41,7 @@ export function exportDemoDocument(data) {
 
 export function updateDocument(data) {
   return request({
-    url: '/document/update',
+    url: '/document/edit',
     method: 'post',
     data
   })
@@ -51,7 +51,7 @@ export function updateDocument(data) {
 
 export function createDocument(data) {
   return request({
-    url: '/document/create',
+    url: '/document/add',
     method: 'post',
     data
   })
@@ -59,21 +59,19 @@ export function createDocument(data) {
 
 
 
-export function getDocumentInfo(data) {
+export function getDocumentInfo(id) {
   return request({
-    url: '/document/info',
-    method: 'post',
-    data
+    url: `/document/info/${id}`,
+    method: 'get'
   })
 }
 
 
 
-export function deleteDocument(data) {
+export function deleteDocument(dcm_id) {
   return request({
-    url: '/document/delete',
-    method: 'post',
-    data
+    url: `/document/dele/${dcm_id}`,
+    method: 'get'
   })
 }
 
@@ -147,7 +145,7 @@ export function searchList(data) {
 
 export function searchlistDoc(data) {
   return request({
-    url: '/document/searchlistDoc',
+    url: '/document/list',
     method: 'post',
     data
   })

+ 8 - 9
ui/src/api/template.js

@@ -67,10 +67,10 @@ export function deleteTemplateCategory(data) {
 }
 
 
-/* 模块列表 /template/pageTemplate*/
+/* 模块列表 */
 export function pageTemplate(data) {
   return request({
-    url: '/template/pageTemplate',
+    url: '/document/block/list',
     method: 'post',
     data
   })
@@ -97,20 +97,19 @@ export function getTemplateInfo(data) {
 
 
 
-export function deleteTemplate(data) {
+export function deleteTemplate(dcbId) {
   return request({
-    url: '/template/delete',
-    method: 'post',
-    data
+    url: `/document/block/dele/${dcbId}`,
+    method: 'get'
   })
 }
 
 
 
-
+/* 新增模板块 */
 export function createTemplate(data) {
   return request({
-    url: '/template/create',
+    url: '/document/block/add',
     method: 'post',
     data
   })
@@ -121,7 +120,7 @@ export function createTemplate(data) {
 
 export function updateTemplate(data) {
   return request({
-    url: '/template/update',
+    url: '/document/block/edit',
     method: 'post',
     data
   })

+ 18 - 3
ui/src/views/ProductMent/ProductManagement.vue

@@ -40,7 +40,16 @@
 
       <el-table :data="productList">
         <el-table-column prop="dcp_oa_code" label="OA编号" />
-        <el-table-column prop="dcp_p_no" label="产品应用编号" />
+        <el-table-column 
+          prop="dcp_p_no" 
+          label="产品应用编号"
+          show-overflow-tooltip
+          :min-width="120"
+        >
+          <template slot-scope="scope">
+            <div class="ellipsis">{{ scope.row.dcp_p_no }}</div>
+          </template>
+        </el-table-column>
         <el-table-column prop="dcp_name" label="产品名称" />
         <el-table-column prop="dcp_model" label="产品类型" />
         <!--  <el-table-column prop="length" label="长宽比" />
@@ -199,7 +208,7 @@ export default {
         categoryId: null,
       },
 
-      // 当前选中的��
+      // 当前选中的
       currentCategory: null,
 
       // 分页参数
@@ -341,7 +350,7 @@ export default {
         this.$message.error("操作失败");
       }
     },
-    /* 删除产��列表 */
+    /* 删除产列表 */
     async handleDeleteProduct(row) {
       try {
         await this.$confirm("确认删除该产品吗?删除后无法恢复", "提示", {
@@ -452,4 +461,10 @@ export default {
   margin-top: 20px;
   text-align: right;
 } */
+
+.ellipsis {
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
 </style>

+ 882 - 827
ui/src/views/ProductMent/newProduct/editor.vue

@@ -1,212 +1,217 @@
 <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="请输入" />
+  <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_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>
-            <el-form-item label="成本价">
-              <el-input
-                v-model="productForm.dcp_cost_price"
-                type="number"
-                placeholder="请输入成本价"
+
+            <!-- 修改规格表单部分 -->
+            <div class="specs-forms">
+              <el-form-item
+                v-for="(spec, index) in productSpec"
+                :key="`spec_${spec.ps_no}_${index}`"
+                :label="spec.psp_name + ':'"
               >
-                <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"
+                <!-- 长宽比输入处理 -->
+                <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)"
                   >
-                    {{ item.psp_name }}
-                  </el-tag>
-                  <el-button
-                    type="text"
-                    icon="el-icon-plus"
-                    @click="showSpecDialog"
-                  ></el-button>
-                </div>
+                    <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 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
+
+            <!--    <div class="button-group">
+                <el-button type="primary" @click="generateSpec">生成</el-button>
+              </div> -->
+          </div>
+        </el-collapse-item>
+      </el-collapse>
+      <el-form-item label="产品应用编码">
+        <el-input
+          v-model="productForm.dcp_p_no"
+          type="textarea"
+          :rows="3"
+          placeholder="自动生成"
+          :readonly="true"
+        />
+      </el-form-item>
+      <!-- 规格列表表格 -->
+      <!--  <el-table
           ref="specTable"
           :data="specsList"
           border
@@ -235,9 +240,6 @@
           </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"
@@ -246,654 +248,707 @@
               >
             </template>
           </el-table-column>
-        </el-table>
-  
-        <div class="button-group">
-          <el-button type="primary" @click="batchAdd">保存</el-button>
-        </div>
+        </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>
-  
-      <!-- 添加规格弹窗 -->
-      <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>
+      <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;
+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: "",
       },
-    },
-    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: "" };
-        }
+      // 规格相关数据
+      specs: {
+        aspectRatio: { width: "", height: "" },
+        refreshRate: "",
+        resolution: "",
+        material: "",
       },
-  
-      // 添加到列表
-      addToList(row) {
-        this.specsList.push({
-          oaNumber: "12345668",
-          dcp_p_no: "DLP11443",
-          dcp_name: "DLP高拼屏",
-          ...row,
-        });
+      specsList: [], // 规格列表
+      rules: {
+        wr_id: [
+          { required: true, message: "请选择工程类别", trigger: "change" },
+        ],
+        sys_no: [
+          { required: true, message: "请选择系统类别", trigger: "change" },
+        ],
       },
-  
-      // 从列表中除
-      removeFromList(index) {
-        this.specsList.splice(index, 1);
+      // 新增数据
+      specForm: {}, // 将改为动态对象
+      // 添加一个临时存储生成规格的数组
+      generatedSpecs: [],
+      specDialogVisible: false,
+      specDialogForm: {
+        code: "",
+        name: "",
+        type: "",
+        value: "",
+        category: "",
       },
-  
-      // 批量添加
-      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;
+      /* 产品规格 */
+      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: {
+    // 添加新方法:生成产品应用编码
+    generateProductCode() {
+      // 创建一个新数组来存储有效的规格信息
+      const validSpecs = this.productSpec.map((spec) => {
+        // 获取当前规格的值
+        let value;
+        if (spec.psp_name.includes("长宽比")) {
+          const values = this.specForm[spec.ps_no];
+          value =
+            values.value1 && values.value2
+              ? `${values.value1}:${values.value2}`
+              : "";
+        } else if (Array.isArray(this.specForm[spec.ps_no])) {
+          value = this.specForm[spec.ps_no].join(",");
+        } else {
+          value = this.specForm[spec.ps_no] || "";
         }
-  
-        const submitData = {
-          content: baseData,
-          specs: this.productSpec,
+
+        // 返回包含必要信息的规格对象
+        return {
+          ps_no: spec.ps_no,
+          psp_name: spec.psp_name,
+          psp_type: spec.psp_type,
+          ps_name: value,
         };
-  
-        // 根据模式调用不同的接口
-        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) => {
+      });
+
+      // 将规格数组转换为JSON字符串并赋值给产品应用编码
+      this.productForm.dcp_p_no = JSON.stringify(validSpecs);
+    },
+    /* 列表选中 */
+    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(
-              `${this.isEdit ? "编辑" : "添加"}失败:${error.message}`
+              res.msg || `${this.isEdit ? "编辑" : "添加"}失败`
             );
-          });
-      },
-  
-      // 保存所有数据
-      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 === "多选" ? [] : "";
           }
+        })
+        .catch((error) => {
+          this.$message.error(
+            `${this.isEdit ? "编辑" : "添加"}失败:${error.message}`
+          );
         });
-        this.specForm = newSpecForm;
-      },
-  
-      // 修改生成规格方法
-      generateSpec() {
-        if (!this.productForm.dcp_oa_code || !this.productForm.dcp_name) {
-          this.$message.warning("请先填写OA编码和产品名称");
-          return;
+    },
+
+    // 保存所有数据
+    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 === "多选" ? [] : "";
         }
-  
-        // 构建规格描述
-        const specValues = {};
-        this.productSpec.forEach((spec) => {
-          // 从 specForm 中获取当前值
-          let currentValue = "";
-  
+      });
+      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.$nextTick(() => {
+        this.generateProductCode();
+      });
+      // 关闭弹窗
+      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();
+          this.$nextTick(() => {
+            this.generateProductCode();
+          });
+        }
+      });
+    },
+
+    // 添加处理编辑模式数据的方法
+    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 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);
+            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.productSpec = specRes;
-            this.initSpecForm();
+            this.specForm[spec.ps_no] = spec.ps_name || ""; // 使用 ps_no
           }
         });
-      },
-  
-      // 添加处理编辑模式数据的方法
-      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 = [];
+
+        // 编辑模式下初始化时不显示列表数据
+        this.specsList = [];
+      }
+      this.$nextTick(() => {
+        this.generateProductCode();
+      });
+    },
+
+    // 添加处理规格输入的方法
+    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}`
+          );
         }
-      },
-  
-      // 添加处理规格输入的方法
-      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(this.specForm, specNo, value);
-          // 立即更新 ps_name
-          if (Array.isArray(value)) {
-            this.$set(currentSpec, "ps_name", value.join(","));
-          } else {
-            this.$set(currentSpec, "ps_name", value);
-          }
+          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,
+      }
+
+      // 强制更新 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.$nextTick(() => {
+        this.generateProductCode();
+      });
+      // 触发视图更新
+      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 {
-                // 添加新规格
-                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();
+              // 处理多选规格
+              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>
+  },
+};
+</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 {
+.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-forms {
+  display: flex;
+  padding: 20px;
+  flex-wrap: wrap;
+  justify-content: flex-start;
+}
+.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>
+
+.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%; /* 使输入框和选择框占满列宽 */
+}
+.ellipsis {
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+::v-deep .el-collapse-item__wrap {
+  border: none;
+}
+</style>

+ 74 - 17
ui/src/views/ProductMent/newProduct/index.vue

@@ -4,7 +4,7 @@
       :model="productForm"
       :rules="rules"
       ref="productForm"
-      label-width="100px"
+      label-width="120px"
     >
       <div class="section-title">产品基本信息</div>
       <!-- 使用 el-row 和 el-col 创建三列布局 -->
@@ -81,9 +81,6 @@
 
         <!-- 第三列 -->
         <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>
@@ -128,7 +125,7 @@
             </el-form-item>
 
             <!-- 修改规格表单部分 -->
-            <div class="specs-form">
+            <div class="specs-forms">
               <el-form-item
                 v-for="(spec, index) in productSpec"
                 :key="`spec_${spec.ps_no}_${index}`"
@@ -198,15 +195,23 @@
               </el-form-item>
             </div>
 
-            <div class="button-group">
+            <!--  <div class="button-group">
               <el-button type="primary" @click="generateSpec">生成</el-button>
-            </div>
+            </div> -->
           </div>
         </el-collapse-item>
       </el-collapse>
-
+      <el-form-item label="产品应用编码">
+        <el-input
+          v-model="productForm.dcp_p_no"
+          type="textarea"
+          :rows="3"
+          placeholder="自动生成"
+          :readonly="true"
+        />
+      </el-form-item>
       <!-- 规格列表表格 -->
-      <el-table
+      <!-- <el-table
         ref="specTable"
         :data="specsList"
         border
@@ -235,9 +240,6 @@
         </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"
@@ -246,7 +248,7 @@
             >
           </template>
         </el-table-column>
-      </el-table>
+      </el-table> -->
 
       <div class="button-group">
         <el-button type="primary" @click="batchAdd">保存</el-button>
@@ -393,6 +395,37 @@ export default {
     this.init();
   },
   methods: {
+    /*  */
+    // 添加新方法:生成产品应用编码
+    generateProductCode() {
+      // 创建一个新数组来存储有效的规格信息
+      const validSpecs = this.productSpec.map((spec) => {
+        // 获取当前规格的值
+        let value;
+        if (spec.psp_name.includes("长宽比")) {
+          const values = this.specForm[spec.ps_no];
+          value =
+            values.value1 && values.value2
+              ? `${values.value1}:${values.value2}`
+              : "";
+        } else if (Array.isArray(this.specForm[spec.ps_no])) {
+          value = this.specForm[spec.ps_no].join(",");
+        } else {
+          value = this.specForm[spec.ps_no] || "";
+        }
+
+        // 返回包含必要信息的规格对象
+        return {
+          ps_no: spec.ps_no,
+          psp_name: spec.psp_name,
+          psp_type: spec.psp_type,
+          ps_name: value,
+        };
+      });
+
+      // 将规格数组转换为JSON字符串并赋值给产品应用编码
+      this.productForm.dcp_p_no = JSON.stringify(validSpecs);
+    },
     /* 列表选中 */
     handleSelectionChange(val) {
       this.multipleSelection = val;
@@ -429,10 +462,10 @@ export default {
 
     // 批量添加
     batchAdd() {
-      if (this.multipleSelection.length === 0) {
+      /* if (this.multipleSelection.length === 0) {
         this.$message.warning("请选择要添加的规格");
         return;
-      }
+      } */
 
       const baseData = {
         wr_id: this.productForm.wr_id,
@@ -605,7 +638,10 @@ export default {
         value: "",
         category: "",
       };
-
+      // 在添加新规格后重新生成产品应用编码
+      this.$nextTick(() => {
+        this.generateProductCode();
+      });
       // 关闭弹窗
       this.specDialogVisible = false;
     },
@@ -628,6 +664,10 @@ export default {
           // 处理新增模式数据
           this.productSpec = specRes;
           this.initSpecForm();
+          // 初始化时生成产品应用编码
+          this.$nextTick(() => {
+            this.generateProductCode();
+          });
         }
       });
     },
@@ -685,6 +725,10 @@ export default {
         // 编辑模式下初始化时不显示列表数据
         this.specsList = [];
       }
+      // 在数据加载完成后生成产品应用编码
+      this.$nextTick(() => {
+        this.generateProductCode();
+      });
     },
 
     // 添加处理规格输入的方法
@@ -723,7 +767,10 @@ export default {
         updatedSpec[currentSpec.psp_name] = currentSpec.ps_name;
         this.$set(this.specsList, 0, updatedSpec);
       }
-
+      // 在规格值更新后重新生成产品应用编码
+      this.$nextTick(() => {
+        this.generateProductCode();
+      });
       // 触发视图更新
       this.$forceUpdate();
     },
@@ -827,6 +874,12 @@ export default {
 .specs-form {
   padding: 20px;
 }
+.specs-forms {
+  display: flex;
+  padding: 20px;
+  flex-wrap: wrap;
+  justify-content: flex-start;
+}
 
 .specs-header {
   display: flex;
@@ -896,4 +949,8 @@ export default {
 ::v-deep .el-select {
   width: 100%; /* 使输入框和选择框占满列宽 */
 }
+
+::v-deep .el-collapse-item__wrap {
+  border: none;
+}
 </style>

+ 2 - 2
ui/src/views/system/document/com/editor.vue

@@ -495,7 +495,7 @@ export default {
           data.id = res.data;
           e.id = res.data;
 
-          _this.$alert("模信息保存成功");
+          _this.$alert("模信息保存成功");
           _this.$emit("onRefresh");
           this.saveAs = false;
           data.selDisabled = false;
@@ -505,7 +505,7 @@ export default {
       } else {
         updateTemplate(data).then((res) => {
           if (res.status != 200) return;
-          _this.$alert("模信息更新成功");
+          _this.$alert("模信息更新成功");
           _this.$emit("onRefresh");
           data.selDisabled = false;
           data.valDisabled = false;

+ 30 - 36
ui/src/views/system/document/components/dataList.vue

@@ -6,40 +6,32 @@
       header-row-class-name="headerBg"
       empty-text="没有文档信息"
     >
-      <el-table-column prop="id" label="ID" align="center" width="80" />
-      <el-table-column
-        prop="title"
-        label="文档名称"
-        align="left"
-        min-width="180"
-      />
-      <el-table-column
+      <el-table-column prop="dcm_id" label="ID" align="center" width="80" />
+      <el-table-column prop="dcm_title" label="文档标题" align="left" />
+      <!-- <el-table-column
         prop="user_name"
         label="创建人"
         align="center"
         width="150"
-      />
-      <el-table-column
-        prop="type_name"
-        label="所属分类"
-        align="center"
-        width="150"
-      />
-      <el-table-column
+      /> -->
+      <el-table-column prop="dcm_type" label="文档模板类别" align="center">
+        <template #default="scope">
+          <div v-if="scope.row.dcm_type == 1">官方模板</div>
+          <div v-if="scope.row.dcm_type == 2">私有模板</div>
+          <div v-if="scope.row.dcm_type == 3">共享模板</div>
+        </template>
+      </el-table-column>
+      <!-- <el-table-column
         prop="create_time"
         label="创建时间"
         align="center"
         width="150"
-      />
-      <el-table-column
-        prop="status"
-        label="文档状态"
-        align="center"
-        width="150"
-      >
+      /> -->
+      <el-table-column prop="status" label="文档状态" align="center">
         <template #default="scope">
-          <div v-if="scope.row.status == 5">启用</div>
-          <div v-if="scope.row.status == 6">停用</div>
+          <div v-if="scope.row.dcm_status == 4">已删除</div>
+          <div v-if="scope.row.dcm_status == 5">启用</div>
+          <div v-if="scope.row.dcm_status == 6">已停用</div>
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center" :width="editWidth()">
@@ -49,7 +41,7 @@
               type="primary"
               size="small"
               v-if="allowEdit"
-              @click="btnEdit(scope.row.id)"
+              @click="btnEdit(scope.row.dcm_id)"
               ><svg-icon icon-class="edit" />编辑</el-button
             >
 
@@ -57,7 +49,7 @@
               type="danger"
               size="small"
               v-if="allowDelete"
-              @click="btnDelete(scope.row.id)"
+              @click="btnDelete(scope.row.dcm_id)"
               ><svg-icon icon-class="delete" />删除</el-button
             >
           </div>
@@ -81,7 +73,7 @@
 </template>
 
 <script>
-import { pageDocument, deleteDocument,searchlistDoc } from "@/api/document";
+import { pageDocument, deleteDocument, searchlistDoc } from "@/api/document";
 export default {
   props: {
     queryForm: {
@@ -90,9 +82,9 @@ export default {
         return {
           page: 1,
           pageSize: 10,
-          title: "",
-          category_id: "",
-          status: "",
+          dcm_title: "",
+          dcm_type: "",
+          isContentShow: false,
         };
       },
     },
@@ -165,7 +157,7 @@ export default {
         })
         .then((res) => {
           // console.log("AAA")
-          deleteDocument(par).then((res) => {
+          deleteDocument(e).then((res) => {
             _this.search();
           });
         })
@@ -180,14 +172,16 @@ export default {
 
     //编辑
     btnEdit(e) {
-      this.$router.push("system/document/create?articleId=" + e + "&type=document");
+      this.$router.push(
+        "system/document/create?articleId=" + e + "&type=document"
+      );
       /* let _this = this;
       let a = document.createElement("a");
       a.href = "#/document/create?articleId=" + e+"&type=document"; // 使用 hash
       a.target = "_blank";
       a.click(); */
 
-       //this.$router.push({path:"/document/create",query:{articleId:e}})
+      //this.$router.push({path:"/document/create",query:{articleId:e}})
     },
 
     handleClose() {
@@ -206,9 +200,9 @@ export default {
             _this.loading = false; // Set loading to false if no response
             return;
           }
-          _this.dataList = res.data.dataList.filter(
+          _this.dataList = res.data.dataList; /* .filter(
             (el) => el.is_template == 0
-          );
+          ); */
           _this.recordCount = res.data.totalRecord;
           _this.pageTotal = res.data.pageTotal;
           _this.loading = false; // Set loading to false after data is processed

+ 22 - 10
ui/src/views/system/document/components/dataSearch.vue

@@ -3,28 +3,40 @@
     <el-form :inline="true" :model="queryForm" class="demo-form-inline">
       <el-form-item label="文档标题:">
         <el-input
-          v-model="queryForm.title"
+          v-model="queryForm.dcm_title"
           placeholder="请填写文档标题"
         ></el-input>
       </el-form-item>
 
       <el-form-item label="所属分类:">
         <el-select
-          v-model="queryForm.category_id"
+          v-model="queryForm.dcm_type"
           clearable
           class="m-2"
           placeholder="请选择分类"
           size="large"
         >
-          <el-option
+          <!-- <el-option
             v-for="item in categoryList"
             :key="item.id"
             :label="item.name"
             :value="item.id"
+          /> -->
+          <el-option
+            label="官方模板"
+            :value="1"
+          />
+          <el-option
+            label="私有模板"
+            :value="2"
           />
+          <el-option
+            label="共享模板"
+            :value="3"
+          /> 
         </el-select>
       </el-form-item>
-      <el-form-item label="文档状态:">
+     <!--  <el-form-item label="文档状态:">
         <el-select
           v-model="queryForm.status"
           class="m-2"
@@ -38,7 +50,7 @@
             :value="item.value"
           />
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
 
       <el-form-item>
         <el-button type="primary" @click="onSubmit">
@@ -67,9 +79,9 @@ export default {
         return {
           page: 1,
           pageSize: 10,
-          title: "",
-          category_id: "",
-          status: "",
+          dcm_title: "",
+          dcm_type: "",
+          isContentShow: false,
         };
       },
     },
@@ -101,9 +113,9 @@ export default {
   },
   methods: {
     checkCreatePermission() {
-      const createPermission = this.$store.state.user.authList.find(
+      /* const createPermission = this.$store.state.user.authList.find(
         (e) => e.code === "createNewDocument"
-      );
+      ); */
       /* this.createNewDocument = !!createPermission; */
     },
 

+ 53 - 46
ui/src/views/system/document/create.vue

@@ -716,37 +716,40 @@
         :model="docForm"
         :rules="docRules"
         ref="docRef"
-        label-position="left"
+        label-position="right"
         label-width="100"
       >
-        <el-form-item label="文档名称:" prop="title">
+        <el-form-item label="文档标题:" prop="dcm_title">
           <el-input
-            v-model="docForm.title"
+            v-model="docForm.dcm_title"
             style="width: 60%"
             class="input-item"
-            placeholder="请填写文档名称"
+            placeholder="请填写文档标题"
             :disabled="docAttr.id > 0"
           />
         </el-form-item>
 
-        <el-form-item label="文档分类:" prop="category_id">
+        <el-form-item label="文档模板类别:" prop="dcm_type">
           <el-select
-            v-model="docForm.category_id"
+            v-model="docForm.dcm_type"
             style="width: 60%"
-            placeholder="请选择所属分类"
+            placeholder="请选择文档模板类别"
             :disabled="docAttr.id > 0"
           >
-            <el-option
+            <!--  <el-option
               v-for="(item, index) in articleCategoryList"
               :key="index"
               :label="item.name"
               :value="item.id"
-            />
+            /> -->
+            <el-option label="官方模板" :value="1" />
+            <el-option label="私有模板" :value="2" />
+            <el-option label="共享模板" :value="3" />
           </el-select>
         </el-form-item>
-        <el-form-item label="创建人:">
+        <!-- <el-form-item label="创建人:">
           {{ userInfo && userInfo.username }}
-        </el-form-item>
+        </el-form-item> -->
       </el-form>
       <span slot="footer" class="dialog-footer">
         <el-button @click="closeDoc">取 消</el-button>
@@ -852,12 +855,14 @@ export default {
       type: "",
       docVisible: false,
       docForm: {
-        title: "",
-        category_id: "",
+        dcm_title: "",
+        dcm_type: "",
       },
       docRules: {
-        title: [{ required: true, message: "请输文档名称", trigger: "blur" }],
-        category_id: [
+        dcm_title: [
+          { required: true, message: "请输文档名称", trigger: "blur" },
+        ],
+        dcm_type: [
           { required: true, message: "请选择文档分类", trigger: "change" },
         ],
       },
@@ -911,7 +916,7 @@ export default {
       ],
       processors: [
         { id: 7, name: "产品选型/处理器/D301/", selected: false },
-        { id: 8, name: "产���选型/处理器/IPWH300/", selected: false },
+        { id: 8, name: "产选型/处理器/IPWH300/", selected: false },
         { id: 9, name: "产品选型/处理器/IPWD400/", selected: false },
       ],
       services: [
@@ -1181,16 +1186,16 @@ export default {
     closeDoc() {
       this.docVisible = false;
       this.docForm = {
-        title: "",
-        category_id: "",
+        dcm_title: "",
+        dcm_type: "",
       };
     },
     /* 确定新增模块*/
     submitDoc() {
       this.$refs.docRef.validate((valid) => {
         if (valid) {
-          this.docAttr.title = this.docForm.title;
-          this.docAttr.category_id = this.docForm.category_id;
+          this.docAttr.dcm_title = this.docForm.dcm_title;
+          this.docAttr.dcm_type = this.docForm.dcm_type;
           this.onSave();
         }
       });
@@ -1661,16 +1666,16 @@ export default {
     async onLoadArticle(id) {
       try {
         this.loading = true;
-        const res = await getDocumentInfo({ id });
+        const res = await getDocumentInfo(id);
 
         if (res.status !== 200) {
           throw new Error("Invalid response status");
         }
 
         this.docAttr = {
-          id: res.data.id,
-          category_id: Number(res.data.category_id),
-          title: res.data.title,
+          dcm_id: res.data.dcm_id,
+          dcm_type: Number(res.data.dcm_type),
+          dcm_title: res.data.dcm_title,
           content: "",
           status: res.data.status,
           is_template: res.data.is_template,
@@ -1681,10 +1686,10 @@ export default {
         };
 
         const templateData =
-          typeof res.data.data === "string"
-            ? JSON.parse(res.data.data)
-            : res.data.data;
-
+          typeof res.data.dcm_data === "string"
+            ? JSON.parse(res.data.dcm_data)
+            : res.data.dcm_data;
+        
         const updatedComs = await Promise.all(
           templateData.map(async (el) => {
             /* let templateInfo = { data: {} };
@@ -1906,8 +1911,8 @@ export default {
     renew() {
       let _this = this;
       _this.docVisible = true;
-      this.docForm.title = _this.docAttr.title;
-      this.docForm.category_id = _this.docAttr.category_id;
+      this.docForm.dcm_title = _this.docAttr.dcm_title;
+      this.docForm.dcm_type = _this.docAttr.dcm_type;
     },
     /* 保存 */
     onSaveAs(e) {
@@ -1916,10 +1921,10 @@ export default {
         _this.$alert("请填写内容");
         return;
       }
-      _this.docAttr.id = "";
+      _this.docAttr.dcm_id = "";
       _this.docVisible = true;
-      this.docForm.title = _this.docAttr.title;
-      this.docForm.category_id = _this.docAttr.category_id;
+      this.docForm.dcm_title = _this.docAttr.dcm_title;
+      this.docForm.dcm_type = _this.docAttr.dcm_type;
     },
     //保存文档
     onSave(e) {
@@ -1928,43 +1933,43 @@ export default {
         _this.$alert("增加组件");
         return;
       }
-      if (_this.docAttr.category_id == "" || _this.docAttr.category_id <= 0) {
+      if (_this.docAttr.dcm_type == "" || _this.docAttr.dcm_type <= 0) {
         _this.$alert("请选择文档分类");
         return;
       }
-      if (_this.docAttr.title == "") {
+      if (_this.docAttr.dcm_title == "") {
         _this.$alert("请填写文档标题");
         return;
       }
 
       _this.docAttr.links = JSON.stringify(_this.docAttr.linkProduct);
       _this.docAttr.projects = JSON.stringify(_this.docAttr.linkProject);
-      _this.docAttr.data = JSON.stringify(_this.coms);
+      _this.docAttr.dcm_data = JSON.stringify(_this.coms);
       _this.docAttr.is_template = 0;
       /* _this.docAttr.user_name = _this.$store.state.user.name;
       _this.docAttr.user_id = _this.$store.state.user.id; 获取用户id,名称 */
-      if (_this.docAttr.id > 0) {
+      if (_this.docAttr.dcm_id > 0) {
         updateDocument(_this.docAttr).then((res) => {
-          if (res.status != 200) return; //更新文档
+          if (res.status !== 200) return; //更新文档
           _this.docAttr.id = res.data;
           _this.$alert("文档更新成功");
           _this.docVisible = false;
           _this.docForm = {
-            title: "",
-            category_id: "",
+            dcm_title: "",
+            dcm_type: "",
           };
           _this.searchArticle();
         });
       } else {
         createDocument(_this.docAttr).then((res) => {
-          if (res.status != 200) return; //保存文档
+          if (res.status !== 200) return; //保存文档
           _this.docAttr.id = res.data;
           _this.articleId = res.data;
           _this.$alert("文档保存成功");
           _this.docVisible = false;
           _this.docForm = {
-            title: "",
-            category_id: "",
+            dcm_title: "",
+            dcm_type: "",
           };
           _this.searchArticle();
         });
@@ -2589,20 +2594,22 @@ export default {
       return dataList;
     },
 
-    //获取文档列表
+    //获取文档模板列表
     searchArticle() {
       let _this = this;
       pageDocument({
         page: 1,
         pageSize: 99,
+        isContentShow: true,
       }).then((res) => {
         if (res.status != 200) return;
-        _this.articleList = res.data.dataList.filter(
+        this.articleList = res.data.dataList;
+        /* _this.articleList = res.data.dataList.filter(
           (el) => el.is_template == 0
         );
         _this.templateList = res.data.dataList.filter(
           (el) => el.is_template == 1
-        );
+        ); */
       });
     },
     // 添加模板选择处理方法

+ 3 - 3
ui/src/views/system/document/search.vue

@@ -26,9 +26,9 @@ export default{
         queryForm:{
           page:1,
           pageSize:10,
-          title:'',
-          category_id:'',
-          status:'',
+          dcm_title:"",
+          dcm_type:'',
+          isContentShow: false,
         },
     }
   },

+ 59 - 40
ui/src/views/system/template/components/dataList.vue

@@ -6,15 +6,16 @@
       empty-text="没有项目信息"
       :max-height="tableMaxHeight"
     >
-      <el-table-column prop="id" label="ID" align="center" width="80" />
+      <el-table-column prop="dcb_id" label="ID" align="center" width="80" />
       <!--  <el-table-column prop="code" label="引用名" align="center" width="180"/> -->
-      <el-table-column prop="name" label="模块名称" align="left" />
-      <el-table-column prop="type_name" label="所属分类" align="left" />
-      <el-table-column prop="create_time" label="创建时间" align="center" />
-      <el-table-column prop="status" label="模板状态" align="center">
+      <el-table-column prop="dcb_name" label="文档块名称" align="center" />
+<!--       <el-table-column prop="dcb_share" label="所属分类" align="left" />
+      <el-table-column prop="create_time" label="创建时间" align="center" /> -->
+      <el-table-column prop="dcb_share" label="共享类型" align="center">
         <template #default="scope">
-          <div v-if="scope.row.status == 5">启用</div>
-          <div v-if="scope.row.status == 6">停用</div>
+          <div v-if="scope.row.dcb_share == 1">官方</div>
+          <div v-if="scope.row.dcb_share == 2">私有</div>
+          <div v-if="scope.row.dcb_share == 3">共享</div>
         </template>
       </el-table-column>
       <el-table-column label="操作" fixed="right" align="center" width="300">
@@ -23,7 +24,7 @@
             <el-button
               type="primary"
               size="small"
-              @click="btnEdit(scope.row.id)"
+              @click="btnEdit(scope.row.dcb_id)"
               ><svg-icon icon-class="edit" />编辑模块</el-button
             >
             <el-button
@@ -35,7 +36,7 @@
             <el-button
               type="danger"
               size="small"
-              @click="btnDelete(scope.row.id)"
+              @click="btnDelete(scope.row.dcb_id)"
               ><svg-icon icon-class="delete" />删除</el-button
             ><!-- v-if="scope.row.auth.delete" -->
           </div>
@@ -72,15 +73,15 @@
         label-position="left"
         label-width="100px"
       >
-        <el-form-item label="模块名称:" prop="name">
+        <el-form-item label="文档块名称:" prop="dcb_name">
           <el-input
             style="width: 220px"
-            v-model="moduleForm.name"
-            placeholder="请选择块名称"
+            v-model="moduleForm.dcb_name"
+            placeholder="请选择文档块名称"
           ></el-input>
         </el-form-item>
-        <el-form-item label="所属分类:" prop="category_id">
-          <el-cascader
+        <el-form-item label="共享类型:" prop="dcb_share">
+         <!--  <el-cascader
             v-model="moduleForm.category_id"
             clearable
             :options="categoryList"
@@ -88,23 +89,23 @@
             :show-all-levels="false"
             @change="onChangeCategory"
             placeholder="请选择模块分类"
-          />
-          <!-- <el-select
-            v-model="moduleForm.category_id"
+          /> -->
+          <el-select
+            v-model="moduleForm.dcb_share"
             clearable
             class="m-2"
-            placeholder="请选择分类"
+            placeholder="请选择共享类型"
             size="large"
           >
             <el-option
-              v-for="item in categoryList"
-              :key="item.id"
-              :label="item.name"
-              :value="item.id"
+              v-for="item in dcbShareList"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
             />
-          </el-select> -->
+          </el-select>
         </el-form-item>
-        <el-form-item label="模块状态:" prop="status">
+        <!-- <el-form-item label="模块状态:" prop="status">
           <el-select
             v-model="moduleForm.status"
             class="m-2"
@@ -118,7 +119,7 @@
               :value="item.value"
             />
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
       </el-form>
       <span slot="footer" class="dialog-footer">
         <el-button @click="closeModule">取 消</el-button>
@@ -176,14 +177,12 @@ export default {
       dialogVisible: false,
       moduleForm: {
         name: "",
-        status: 5,
-        category_id: "",
+        dcb_share: "",
       },
       moduleRules: {
-        name: [{ required: true, message: "请输模块名称", trigger: "blur" }],
-        status: [{ required: true, message: "请选择状态", trigger: "change" }],
-        category_id: [
-          { required: true, message: "请选择分类", trigger: "change" },
+        dcb_name: [{ required: true, message: "请输入文档块名称", trigger: "blur" }],
+        dcb_share: [
+          { required: true, message: "请选择共享类型", trigger: "change" },
         ],
       },
       props: {
@@ -208,6 +207,22 @@ export default {
       ],
       categoryList:[],
       tableMaxHeight: 500, // Add this line
+
+      /* 共享类型 */
+      dcbShareList: [
+        {
+          value: 1,
+          label: "官方",
+        },
+        {
+          value: 2,
+          label: "私有",
+        },
+        {
+          value: 3,
+          label: "共享",
+        },
+      ],
     };
   },
   mounted() {
@@ -215,15 +230,17 @@ export default {
     this.initCategoryList();
   },
   methods: {
+    refreshList() {
+    this.search();
+  },
     /* 选择模块分类 */
     onChangeCategory(){},
      /* 取消修改 */
      closeModule() {
       this.dialogVisible = false;
       this.moduleForm = {
-        name: "",
-        status: 5,
-        category_id: "",
+        dcb_name: "",
+        dcb_share: "",
       };
     },
     /* 确定修改模块*/
@@ -231,15 +248,16 @@ export default {
       this.$refs.moduleRef.validate((valid) => {
         if (valid) {
           updateTemplate(this.moduleForm).then((res) => {
-            if (res.status !== 200) return;
+            if (res.code !== 200) return;
             this.$message.success("修改成功!");
             this.dialogVisible = false;
             this.moduleForm = {
-              name: "",
-              status: 5,
-              category_id: "",
+              dcb_name: "",
+              dcb_share: "",
             };
-            this.onSubmit()
+            //this.onSubmit()
+             // 修改这里:直接调用 search 方法而不是 onSubmit
+        this.search();
           });
         }
       });
@@ -278,8 +296,9 @@ export default {
           type: "warning",
         })
         .then((res) => {
+          console.log(e);
           // console.log("AAA")
-          deleteTemplate(par).then((res) => {
+          deleteTemplate(e).then((res) => {
             _this.search();
           });
         })

+ 67 - 46
ui/src/views/system/template/components/dataSearch.vue

@@ -1,29 +1,29 @@
 <template>
   <div class="data-search">
     <el-form :inline="true" :model="queryForm" class="demo-form-inline">
-      <el-form-item label="块名称:">
+      <el-form-item label="文档块名称:">
         <el-input
-          v-model="queryForm.name"
-          placeholder="请选择块名称"
+          v-model="queryForm.dcb_name"
+          placeholder="请选择文档块名称"
         ></el-input>
       </el-form-item>
       <el-form-item label="所属分类:">
         <el-select
-          v-model="queryForm.category_id"
+          v-model="queryForm.dcb_share"
           clearable
           class="m-2"
           placeholder="请选择分类"
           size="large"
         >
           <el-option
-            v-for="item in categoryList"
-            :key="item.id"
-            :label="item.name"
-            :value="item.id"
+            v-for="item in dcbShareList"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
           />
         </el-select>
       </el-form-item>
-      <el-form-item label="模块状态:">
+     <!--  <el-form-item label="模块状态:">
         <el-select
           v-model="queryForm.status"
           class="m-2"
@@ -37,7 +37,7 @@
             :value="item.value"
           />
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
 
       <el-form-item>
         <el-button type="primary" @click="onSubmit">
@@ -64,15 +64,15 @@
         label-position="right"
         label-width="100px"
       >
-        <el-form-item label="模块名称:" prop="name">
+        <el-form-item label="文档块名称:" prop="dcb_name">
           <el-input
             style="width: 220px"
-            v-model="moduleForm.name"
-            placeholder="请选择块名称"
+            v-model="moduleForm.dcb_name"
+            placeholder="请选择文档块名称"
           ></el-input>
         </el-form-item>
-        <el-form-item label="所属分类:" prop="category_id">
-          <el-cascader
+        <el-form-item label="共享类型:" prop="dcb_share">
+          <!--  <el-cascader
             v-model="moduleForm.category_id"
             clearable
             :options="categoryList"
@@ -80,23 +80,23 @@
             :show-all-levels="false"
             @change="onChangeCategory"
             placeholder="请选择模块分类"
-          />
-          <!-- <el-select
-            v-model="moduleForm.category_id"
+          /> -->
+          <el-select
+            v-model="moduleForm.dcb_share"
             clearable
             class="m-2"
             placeholder="请选择分类"
             size="large"
           >
             <el-option
-              v-for="item in categoryList"
-              :key="item.id"
-              :label="item.name"
-              :value="item.id"
+              v-for="item in dcbShareList"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
             />
-          </el-select> -->
+          </el-select>
         </el-form-item>
-        <el-form-item label="模块状态:" prop="status">
+        <!--  <el-form-item label="模块状态:" prop="status">
           <el-select
             v-model="moduleForm.status"
             class="m-2"
@@ -110,7 +110,7 @@
               :value="item.value"
             />
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
       </el-form>
       <span slot="footer" class="dialog-footer">
         <el-button type="primary" @click="closeModule">取 消</el-button>
@@ -127,7 +127,7 @@ import {
   searchTemplateCategory,
   createTemplate,
   getAllList,
-  treeCategory
+  treeCategory,
 } from "@/api/template";
 export default {
   components: {
@@ -141,9 +141,9 @@ export default {
         return {
           page: 1,
           pageSize: 10,
-          name: "",
-          category_id: "",
-          status: "",
+          dcb_name: "",
+          dcb_share: "",
+          /*           status: "", */
         };
       },
     },
@@ -167,9 +167,9 @@ export default {
       categoryList: [],
       dialogVisible: false,
       moduleForm: {
-        name: "",
-        status: 5,
-        category_id: "",
+        dcb_name: "",
+        /*  status: 5, */
+        dcb_share: "",
       },
       props: {
         value: "id",
@@ -178,42 +178,59 @@ export default {
         checkStrictly: true,
       },
       moduleRules: {
-        name: [{ required: true, message: "请输模块名称", trigger: "blur" }],
-        status: [{ required: true, message: "请选择状态", trigger: "change" }],
-        category_id: [
+        dcb_name: [
+          { required: true, message: "请输模块名称", trigger: "blur" },
+        ],
+        /*  status: [{ required: true, message: "请选择状态", trigger: "change" }], */
+        dcb_share: [
           { required: true, message: "请选择分类", trigger: "change" },
         ],
       },
+      /* 共享类型 */
+      dcbShareList: [
+        {
+          value: 1,
+          label: "官方",
+        },
+        {
+          value: 2,
+          label: "私有",
+        },
+        {
+          value: 3,
+          label: "共享",
+        },
+      ],
     };
   },
   mounted() {
     this.initCategoryList();
   },
   methods: {
-    onChangeCategory(){},
+    onChangeCategory() {},
     /* 取消新增 */
     closeModule() {
       this.dialogVisible = false;
       this.moduleForm = {
-        name: "",
-        status: 5,
-        category_id: "",
+        dcb_name: "",
+        dcb_share: "",
       };
     },
     /* 确定新增模块*/
     submitModule() {
       this.$refs.moduleRef.validate((valid) => {
         if (valid) {
-          this.moduleForm.category_id = this.moduleForm.category_id[this.moduleForm.category_id.length - 1];
+          /*  this.moduleForm.category_id = this.moduleForm.category_id[this.moduleForm.category_id.length - 1]; */
           createTemplate(this.moduleForm).then((res) => {
-            if (res.status !== 200) return;
+            if (res.code !== 200) return;
             this.$message.success("创建成功!");
             this.dialogVisible = false;
             this.moduleForm = {
-              name: "",
-              status: 5,
-              category_id: "",
+              dcb_name: "",
+              /*    status: 5, */
+              dcb_share: "",
             };
+            //this.$emit('refresh-list');
             this.onSubmit();
           });
         }
@@ -244,9 +261,13 @@ export default {
     },
 
     //搜索
+   // 修改 onSubmit 方法
     onSubmit() {
-      this.$emit("bindSetQuery", this.$props.queryForm);
-    },
+      // 更新查询条件
+      this.$emit("bindSetQuery", this.queryForm);
+      // 触发刷新列表
+      this.$emit("search");
+    }
   },
 };
 </script>

+ 5 - 3
ui/src/views/system/template/search.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="project-search">
-    <dataSearch @bindSetQuery="setQuery"></dataSearch>
-    <dataList :queryForm="queryForm"></dataList>
+    <dataSearch @bindSetQuery="setQuery" @refresh-list="handleRefreshList"></dataSearch>
+    <dataList  ref="dataList" :queryForm="queryForm"></dataList>
   </div>
 
 </template>
@@ -29,7 +29,9 @@ export default{
     this.queryForm.parent_id=this.$route.query.parent_id==undefined?0:this.$route.query.parent_id;
   },
   methods:{
-
+    handleRefreshList() {
+      this.$refs.dataList.refreshList();
+    },
     setQuery(e){
       this.queryForm=e;
     }