From 64f45c75ea93911b9841bf00bb4c436cd294be3a Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期五, 15 九月 2023 18:30:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 company_admin/src/components/business/OperaCategoryWindow.vue |  278 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 219 insertions(+), 59 deletions(-)

diff --git a/company_admin/src/components/business/OperaCategoryWindow.vue b/company_admin/src/components/business/OperaCategoryWindow.vue
index b08bb82..89cde75 100644
--- a/company_admin/src/components/business/OperaCategoryWindow.vue
+++ b/company_admin/src/components/business/OperaCategoryWindow.vue
@@ -5,7 +5,25 @@
       :confirm-working="isWorking"
       @confirm="confirm"
     >
+      <el-alert title="濡傛灉浠庡钩鍙伴�夋嫨鍟嗗搧杩涜鐩存挱锛屽缓璁被鍒�夋嫨浠庡钩鍙板簱閫夋嫨锛岀郴缁熷凡鍋氭暟鎹叧鑱旓紱" type="warning" effect="dark" :closable="false"></el-alert>
+      <h3 style="margin: 20px 0 10px 0;">鍩烘湰淇℃伅</h3>
       <el-form :model="form" ref="form" :rules="rules">
+        <el-form-item label="绫诲埆鏉ユ簮" prop="type">
+          <el-radio-group v-model="form.type" @change="changeRadio">
+            <el-radio :label="1">浠庡钩鍙板簱閫夋嫨</el-radio>
+            <el-radio :label="0">浼佷笟鑷缓</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item label="閫夋嫨绫诲埆" prop="platCateId" v-if="form.type == 1">
+          <el-select v-model="form.platCateId" placeholder="璇烽�夋嫨" @change="changeCategory">
+            <el-option
+              v-for="item in categoryList"
+              :key="item.id"
+              :label="item.name"
+              :value="item.id">
+            </el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="绫诲埆鍚嶇О" prop="name">
           <el-input v-model="form.name" placeholder="璇疯緭鍏ョ被鍒悕绉帮紝涓嶈秴杩�6涓瓧" maxlength="6" v-trim/>
         </el-form-item>
@@ -14,7 +32,7 @@
             :action="action"
             :class="{ hide: hideUpload }"
             :file-list="form.fileList"
-            :data="{ folder: 'projects' }"
+            :data="{ folder: 'category_img' }"
             list-type="picture-card"
             :limit="1"
             :on-success="fileSuccess"
@@ -23,13 +41,56 @@
             <i class="el-icon-plus"></i>
             <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�120*120px</div>
           </el-upload>
-          <!-- <el-input v-model="form.imgurl" placeholder="璇疯緭鍏ュ浘鏍�" v-trim/> -->
         </el-form-item>
         <el-form-item label="鎺掑簭鐮�(鍗囧簭)" prop="sortnum">
           <el-input v-model="form.sortnum" placeholder="璇疯緭鍏ユ帓搴忕爜" v-trim/>
         </el-form-item>
 
-        <el-form-item label="绛涢�夊睘鎬�1鍚嶇О" prop="attrFirst">
+        <div style="margin: 20px 0 10px 0; height: 30px; display: flex; justify-content: space-between;">
+          <h3 style="display: flex; align-items: flex-end;">鍙傛暟灞炴�ч厤缃�<h6 style="margin-left: 10px;">閰嶇疆褰撳墠绫诲埆鐨勪骇鍝佸弬鏁板悕</h6></h3>
+          <el-button style="display: inline-block;" type="primary" v-if="form.type == 0" @click="addItem">+ 鏂板</el-button>
+        </div>
+        <el-table
+          :data="form.tableData"
+          border
+          style="width: 100%">
+          <el-table-column label="鍙傛暟鍚�">
+            <template slot-scope="scope">
+              <el-input v-model="scope.row.name" placeholder="璇疯緭鍏ュ唴瀹�"></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column label="璁剧疆涓洪�夐」">
+            <template slot-scope="scope">
+              <el-switch
+                v-model="scope.row.isselect"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+                :active-value="1"
+                :inactive-value="0">
+              </el-switch>
+            </template>
+          </el-table-column>
+          <el-table-column label="鏄惁鏄剧ず">
+            <template slot-scope="scope">
+              <el-switch
+                v-model="scope.row.isshow"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+                :active-value="1"
+                :inactive-value="0">
+              </el-switch>
+            </template>
+          </el-table-column>
+          <el-table-column label="鎿嶄綔" v-if="form.type == 0">
+            <template slot-scope="scope">
+              <el-button
+                size="mini"
+                type="danger"
+                @click="handleDelete(scope.$index)">鍒犻櫎</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <!-- <el-form-item label="绛涢�夊睘鎬�1鍚嶇О" prop="attrFirst">
           <el-input v-model="form.attrFirst" maxlength="6" placeholder="璇疯緭鍏ョ瓫閫夊睘鎬у悕绉帮紝涓嶈秴杩�6涓瓧" v-trim/>
         </el-form-item>
         <el-form-item label="绛涢�夊睘鎬�1鐨勫��" prop="attrFirst">
@@ -53,8 +114,9 @@
           <div style="display: flex; align-items: center; flex-wrap: wrap;">
             <el-tag style="margin-right: 10px; margin-top: 10px;" @close="close(index, 3)" closable v-for="(item, index) in form.paramList" :key="index">{{ item.name }}</el-tag>
           </div>
-        </el-form-item>
+        </el-form-item> -->
 
+        <h3 style="margin: 20px 0 10px 0; display: flex; align-items: flex-end;">棰勭畻鍖洪棿閰嶇疆<h6 style="margin-left: 10px;">閰嶇疆褰撳墠绫诲埆鐨勯绠楀尯闂寸瓫閫夊�硷紝涓婇檺鍜屼笅闄愪笉鑳藉悓鏃朵负绌�</h6></h3>
         <el-form-item label="棰勭畻鍖洪棿" prop="attrSecond">
           <div style="display: flex; align-items: center; margin-bottom: 10px;" v-for="(item, index) in form.budgetList" :key="index">
             <el-input v-model="item.minamount" type="number" @input="changeInput(1, index)" placeholder="涓嬮檺" v-trim/>
@@ -71,31 +133,35 @@
   <script>
   import BaseOpera from '@/components/base/BaseOpera'
   import GlobalWindow from '@/components/common/GlobalWindow'
-  import { create, updateById } from '@/api/business/category.js'
+  import { create, updateById, baseCategoryList, companyCreate, companyUpdateById } from '@/api/business/category.js'
   export default {
     name: 'OperaCategoryWindow',
     extends: BaseOpera,
     components: { GlobalWindow },
     data () {
       return {
-        action: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
+        action: process.env.VUE_APP_API_PREFIX + '/public/upload',
 
         hideUpload: false,
+        categoryList: [],
         
         // 琛ㄥ崟鏁版嵁
         form: {
           id: null,
+          type: 1,
+          platCateId: '',
           name: '',
-          attrFirst: '',
-          attrFirst1: '',
-          attrFirstList: [],
-          attrSecond: '',
-          attrSecond1: '',
-          attrSecondList: [],
+          // attrFirst: '',
+          // attrFirst1: '',
+          // attrFirstList: [],
+          // attrSecond: '',
+          // attrSecond1: '',
+          // attrSecondList: [],
           sortnum: '',
-          parameter: '',
+          // parameter: '',
           paramList: [],
           imgurl: '',
+          tableData: [],
           budgetList: [
             {
               maxamount: '',
@@ -103,7 +169,7 @@
             }
           ],
           fileList: [],
-          attributeValueOne: []
+          // attributeValueOne: []
         },
         // 楠岃瘉瑙勫垯
         rules: {
@@ -121,6 +187,91 @@
       })
     },
     methods: {
+      addItem() {
+        this.form.tableData.push({ name: '', isselect: 0, isshow: 1 })
+      },
+      handleDelete(index) {
+        this.form.tableData.splice(index, 1)
+      },
+      changeRadio(e) {
+        this.form.name = ''
+        this.form.platCateId = ''
+        this.form.sortnum = ''
+        this.form.tableData = []
+        this.form.imgurl = ''
+        this.form.fileList = []
+        this.form.budgetList = [{
+          maxamount: '',
+          minamount: ''
+        }]
+      },
+      confirm() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) return
+          // 璋冪敤鏂板缓鎺ュ彛
+          this.isWorking = true
+          if (!this.form.id) {
+            companyCreate({
+              paramList: this.form.tableData,
+              type: this.form.type,
+              sortnum: this.form.sortnum,
+              platCateId: this.form.platCateId,
+              name: this.form.name,
+              imgurl: this.form.imgurl,
+              budgetList: this.form.budgetList
+            })
+              .then(() => {
+                this.visible = false
+                this.$tip.apiSuccess('鏂板缓鎴愬姛')
+                this.$emit('success')
+              })
+              .catch(e => {
+                this.$tip.apiFailed(e)
+              })
+              .finally(() => {
+                this.isWorking = false
+              })
+          } else {
+            companyUpdateById({
+              id: this.form.id,
+              paramList: this.form.tableData,
+              type: this.form.type,
+              sortnum: this.form.sortnum,
+              platCateId: this.form.platCateId,
+              name: this.form.name,
+              imgurl: this.form.imgurl,
+              budgetList: this.form.budgetList
+            })
+              .then(() => {
+                this.visible = false
+                this.$tip.apiSuccess('缂栬緫鎴愬姛')
+                this.$emit('success')
+              })
+              .catch(e => {
+                this.$tip.apiFailed(e)
+              })
+              .finally(() => {
+                this.isWorking = false
+              })
+          }
+        })
+      },
+      // 鍒囨崲鍒嗙被
+      changeCategory(id) {
+        this.categoryList.forEach(item => {
+          if (item.id === id) {
+            this.form.name = item.name
+            this.form.sortnum = item.sortnum
+            let arr = []
+            item.baseCateParamList.forEach((row, index) => {
+              arr.push({ name: row.name, isselect: index <= 1 ? 1 : 0, isshow: 1 })
+            })
+            this.form.tableData = arr
+            this.form.imgurl = item.imgurl
+            this.form.fileList = [{ url: item.imgfullurl }]
+          }
+        })
+      },
       changeInput(type, index) {
         if (type === 1) {
           if (!this.form.budgetList[index].minamount) return
@@ -147,42 +298,42 @@
           message: '鍙兘涓婁紶涓�涓浘鏍�'
         })
       },
-      confirm() {
-        this.$refs.form.validate((valid) => {
-          if (valid) {
-            this.isWorking = true
-            if (!this.form.id) {
-              create(this.form)
-              .then(() => {
-                this.visible = false
-                this.$tip.apiSuccess('鏂板缓鎴愬姛')
-                this.$emit('success')
-              })
-              .catch(e => {
-                this.$tip.apiFailed(e)
-              })
-              .finally(() => {
-                this.isWorking = false
-              })
-            } else {
-              updateById(this.form)
-                .then(() => {
-                  this.visible = false
-                  this.$tip.apiSuccess('缂栬緫鎴愬姛')
-                  this.$emit('success')
-                })
-                .catch(e => {
-                  this.$tip.apiFailed(e)
-                })
-                .finally(() => {
-                  this.isWorking = false
-                })
-            }
-          } else {
-            return false;
-          }
-        });
-      },
+      // confirm() {
+      //   this.$refs.form.validate((valid) => {
+      //     if (valid) {
+      //       this.isWorking = true
+      //       if (!this.form.id) {
+      //         create(this.form)
+      //         .then(() => {
+      //           this.visible = false
+      //           this.$tip.apiSuccess('鏂板缓鎴愬姛')
+      //           this.$emit('success')
+      //         })
+      //         .catch(e => {
+      //           this.$tip.apiFailed(e)
+      //         })
+      //         .finally(() => {
+      //           this.isWorking = false
+      //         })
+      //       } else {
+      //         updateById(this.form)
+      //           .then(() => {
+      //             this.visible = false
+      //             this.$tip.apiSuccess('缂栬緫鎴愬姛')
+      //             this.$emit('success')
+      //           })
+      //           .catch(e => {
+      //             this.$tip.apiFailed(e)
+      //           })
+      //           .finally(() => {
+      //             this.isWorking = false
+      //           })
+      //       }
+      //     } else {
+      //       return false;
+      //     }
+      //   });
+      // },
       close(index, type) {
         if (type === 1) {
           this.form.attrFirstList.splice(index, 1)
@@ -230,15 +381,18 @@
             this.form = {
               id: null,
               name: '',
-              attrFirst: '',
-              attrFirst1: '',
-              attrFirstList: [],
-              attrSecond: '',
-              attrSecond1: '',
-              attrSecondList: [],
+              type: 1,
+              platCateId: '',
+              tableData: [],
+              // attrFirst: '',
+              // attrFirst1: '',
+              // attrFirstList: [],
+              // attrSecond: '',
+              // attrSecond1: '',
+              // attrSecondList: [],
               sortnum: '',
-              parameter: '',
-              paramList: [],
+              // parameter: '',
+              // paramList: [],
               imgurl: '',
               budgetList: [
                 {
@@ -247,8 +401,14 @@
                 }
               ],
               fileList: [],
-              attributeValueOne: []
+              // attributeValueOne: []
             }
+          } else {
+            // 鑾峰彇鍒嗙被鍒楄〃
+            baseCategoryList({})
+              .then(res => {
+                this.categoryList = res
+              })
           }
         }
       }

--
Gitblit v1.9.3