From 02eb974bcf9f85a4a6594540fab97007abef4291 Mon Sep 17 00:00:00 2001
From: Mr.Shi <1878285526@qq.com>
Date: 星期二, 19 九月 2023 09:19:24 +0800
Subject: [PATCH] 企业端

---
 company_admin/src/components/business/selectProduct.vue |  153 ++++++++++++++++++++++++++-------------------------
 1 files changed, 78 insertions(+), 75 deletions(-)

diff --git a/company_admin/src/components/business/selectProduct.vue b/company_admin/src/components/business/selectProduct.vue
index 8137bca..cdea603 100644
--- a/company_admin/src/components/business/selectProduct.vue
+++ b/company_admin/src/components/business/selectProduct.vue
@@ -1,36 +1,36 @@
 <template>
-    <GlobalWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm">
-      <el-form :model="form" ref="form" :rules="rules">
-        <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
-            <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨">
-                <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="type">
-            <el-radio-group v-model="form.type">
-                <el-radio :label="0">鍏ㄩ儴</el-radio>
-                <el-radio :label="1">閮ㄥ垎</el-radio>
-            </el-radio-group>
-        </el-form-item>
-        <el-form-item label="鍔犱环绯绘暟" prop="rate">
-          <el-input v-model="form.rate" placeholder="骞冲彴閲囪喘浠�*鍔犱环绯绘暟锛屼綔涓哄弬鑰冨嚭鎵嬩环锛屽缓璁緭鍏ュぇ浜�1鐨勬暟瀛�" v-trim />
-        </el-form-item>
-      </el-form>
-      <!-- 閫夋嫨骞冲彴鍟嗗搧 -->
-      <selectProductItem ref="selectProductItem" @result="result" />
-    </GlobalWindow>
-  </template>
+  <GlobalWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm">
+    <el-form :model="form" ref="form" :rules="rules">
+      <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
+        <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨">
+          <el-option
+            v-for="item in categoryList"
+            :key="item.id"
+            :label="item.name"
+            :value="`${item.platCateId},${item.id}`">
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="鍟嗗搧鑼冨洿" prop="type">
+        <el-radio-group v-model="form.type">
+          <el-radio :label="0">鍏ㄩ儴</el-radio>
+          <el-radio :label="1">閮ㄥ垎</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="鍔犱环绯绘暟" prop="rate">
+        <el-input v-model="form.rate" placeholder="骞冲彴閲囪喘浠�*鍔犱环绯绘暟锛屼綔涓哄弬鑰冨嚭鎵嬩环锛屽缓璁緭鍏ュぇ浜�1鐨勬暟瀛�" v-trim />
+      </el-form-item>
+    </el-form>
+    <!-- 閫夋嫨骞冲彴鍟嗗搧 -->
+    <selectProductItem ref="selectProductItem" @result="result" />
+  </GlobalWindow>
+</template>
     
-  <script>
+<script>
   import BaseOpera from '@/components/base/BaseOpera'
   import GlobalWindow from '@/components/common/GlobalWindow'
   import selectProductItem from '@/components/business/selectProductItem'
-  import { baseCategoryList } from '@/api/business/category.js'
+  import { list } from '@/api/business/category.js'
   import { createPlat } from '@/api/business/goods'
 
   export default {
@@ -48,7 +48,7 @@
         },
         // 楠岃瘉瑙勫垯
         rules: {
-            categoryId: [
+          categoryId: [
             { required: true, message: '鍟嗗搧绫诲埆涓嶈兘涓虹┖', trigger: 'blur' }
           ],
           type: [
@@ -67,53 +67,56 @@
       })
     },
     methods: {
-        result() {
-          // this.$emit('success')
-          this.$emit('result')
-          this.visible = false
-        },
-        confirm() {
-            this.$refs.form.validate((valid) => {
-                if (!valid) return
-                // 鏂板缓
-                if (this.form.type == 0) {
-                    this.isWorking = true
-                    createPlat({
-                        categoryId: this.form.categoryId,
-                        rate: this.form.rate,
-                        type: this.form.type
-                    }).then(res => {
-                        this.visible = false
-                        this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
-                        // this.$emit('success')
-                        this.$emit('result')
-                    })
-                    .catch(e => {
-                        this.$tip.apiFailed(e)
-                    })
-                    .finally(() => {
-                        this.isWorking = false
-                    })
-                } else {
-                    this.$refs.selectProductItem.open('閫夋嫨骞冲彴鍟嗗搧', this.form)
-                }
+      result() {
+        // this.$emit('success')
+        this.$emit('result')
+        this.visible = false
+      },
+      confirm() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) return
+          // 鏂板缓
+          if (this.form.type == 0) {
+            this.isWorking = true
+            createPlat({
+              categoryId: this.form.categoryId.split(',')[1],
+              rate: this.form.rate,
+              type: this.form.type
+            }).then(res => {
+              this.visible = false
+              this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
+              // this.$emit('success')
+              this.$emit('result')
             })
-        },
-        /**
-         * 鎵撳紑绐楀彛
-         * @title 绐楀彛鏍囬
-         * @target 缂栬緫鐨勫璞�
-         */
-        open (title, target) {
-            this.title = title
-            this.visible = true
-            // 鑾峰彇鍒嗙被鍒楄〃
-            baseCategoryList({ type: 1 })
-              .then(res => {
-                this.categoryList = res
-              })
-        }
+            .catch(e => {
+              this.$tip.apiFailed(e)
+            })
+            .finally(() => {
+              this.isWorking = false
+            })
+          } else {
+            this.$refs.selectProductItem.open('閫夋嫨骞冲彴鍟嗗搧', this.form)
+          }
+        })
+      },
+      /**
+       * 鎵撳紑绐楀彛
+       * @title 绐楀彛鏍囬
+       * @target 缂栬緫鐨勫璞�
+       */
+      open (title, target) {
+        this.title = title
+        this.visible = true
+        this.form.categoryId = ''
+        this.form.type = 0
+        this.form.rate = ''
+        // 鑾峰彇鍒嗙被鍒楄〃
+        list({ type: 1 })
+          .then(res => {
+            this.categoryList = res
+          })
+      }
     }
   }
-  </script>
+</script>
     
\ No newline at end of file

--
Gitblit v1.9.3