wangn 5 лет назад
Родитель
Сommit
6ffb7a8b9c
1 измененных файлов с 109 добавлено и 48 удалено
  1. 109 48
      ghs/src/components/module/item-list-layer.vue

+ 109 - 48
ghs/src/components/module/item-list-layer.vue

@@ -1,13 +1,34 @@
 <template>
-  <el-dialog title="选择花材" :visible.sync="selDialog" :close-on-click-modal="false" :append-to-body="true" @close="$emit('update:show', false)" width="950px">
+  <el-dialog
+    title="选择花材"
+    :visible.sync="selDialog"
+    :close-on-click-modal="false"
+    :append-to-body="true"
+    @close="$emit('update:show', false)"
+    width="950px"
+  >
     <div class="recharge-modal-content">
-      <el-checkbox-group v-model="checkList" class="radio-wrap" >
+      <el-checkbox-group
+        v-model="checkList"
+        class="radio-wrap"
+      >
 
-        <x-crud class="liu-crud-wrap" @load="onLoad">
+        <x-crud
+          class="liu-crud-wrap"
+          @load="onLoad"
+        >
           <template #table-column-radio="{scope}">
             <div>
-              <el-checkbox v-if="scope.row.select == 2" disabled :label="scope.row" >{{scope.row.id}}</el-checkbox>
-              <el-checkbox v-else :label="scope.row" @click.stop.native="stop" >{{scope.row.id}}</el-checkbox>
+              <el-checkbox
+                v-if="scope.row.select == 2"
+                disabled
+                :label="scope.row"
+              >{{scope.row.id}}</el-checkbox>
+              <el-checkbox
+                v-else
+                :label="scope.row"
+                @click.stop.native="stop"
+              >{{scope.row.id}}</el-checkbox>
             </div>
           </template>
 
@@ -17,20 +38,40 @@
           </template>
 
           <template #table-column-stockWarning="{scope}">
-            <el-input v-model="scope.row.stockWarning" @click.stop.native="stop" placeholder="库存预警值" size="small"></el-input>
+            <el-input
+              v-model="scope.row.stockWarning"
+              @click.stop.native="stop"
+              placeholder="库存预警值"
+              size="small"
+            ></el-input>
           </template>
 
           <template #table-column-cost="{scope}">
-            <el-input v-model="scope.row.cost" placeholder="成本价" @click.stop.native="stop" size="small" ></el-input>
+            <el-input
+              v-model="scope.row.cost"
+              placeholder="成本价"
+              @click.stop.native="stop"
+              size="small"
+            ></el-input>
           </template>
 
           <template #table-column-addPrice="{scope}">
-            <el-input v-model="scope.row.addPrice" placeholder="加价" @click.stop.native="stop" size="small"></el-input>
+            <el-input
+              v-model="scope.row.addPrice"
+              placeholder="加价"
+              @click.stop.native="stop"
+              size="small"
+            ></el-input>
           </template>
 
           <template #table-column-cover="{scope}">
             <div>
-              <cl-avatar shape="square" :size="40" :src="scope.row.cover | default_avatar" :style="{ margin: 'auto' }" ></cl-avatar>
+              <cl-avatar
+                shape="square"
+                :size="40"
+                :src="scope.row.cover | default_avatar"
+                :style="{ margin: 'auto' }"
+              ></cl-avatar>
             </div>
           </template>
         </x-crud>
@@ -39,16 +80,36 @@
 
       <div>
         <span>花材分类:</span>
-        <el-select style="width:300px;" v-model="sonClassName" size="small" placeholder="请选择分类" @change="selClassFn">
-          <el-option v-for="(item, index) in itemClassList" :key="index" :value="item.name">{{ item.name }}</el-option>
+        <el-select
+          style="width:300px;"
+          v-model="sonClassName"
+          size="small"
+          placeholder="请选择分类"
+          @change="selClassFn"
+        >
+          <el-option
+            v-for="(item, index) in itemClassList"
+            :key="index"
+            :value="item.name"
+          >{{ item.name }}</el-option>
         </el-select>
       </div>
 
     </div>
 
-    <div slot="footer" class="dialog-footer">
-      <el-button size="small" @click="resetForm" >取 消</el-button>
-      <el-button type="primary" size="small" @click="confirmFn">确定</el-button>
+    <div
+      slot="footer"
+      class="dialog-footer"
+    >
+      <el-button
+        size="small"
+        @click="resetForm"
+      >取 消</el-button>
+      <el-button
+        type="primary"
+        size="small"
+        @click="confirmFn"
+      >确定</el-button>
     </div>
 
   </el-dialog>
@@ -70,9 +131,9 @@ export default {
       type: Boolean,
       default: false
     },
-    className:{
+    className: {
       type: String,
-      default:''
+      default: ''
     }
   },
   data () {
@@ -82,9 +143,9 @@ export default {
       checkList: [],
       list: [],
       //分类列表
-			itemClassList: [],
-      sonClassId:0,
-      sonClassName:''
+      itemClassList: [],
+      sonClassId: 0,
+      sonClassName: ''
     };
   },
   computed: {
@@ -96,46 +157,46 @@ export default {
   },
   created () { },
   methods: {
-    stop(){},
-    selClassFn(val){
-			let index = this.itemClassList.findIndex((e) => e.name == val)
-			this.sonClassId = this.itemClassList[index].id
+    stop () { },
+    selClassFn (val) {
+      let index = this.itemClassList.findIndex((e) => e.name == val)
+      this.sonClassId = this.itemClassList[index].id
+    },
+    getAllClass () {
+      if (!this.$util.isEmpty(this.itemClassList)) {
+        return this.itemClassList
+      }
+      this.$service.itemClass.getAllClass().then((res) => {
+        this.itemClassList = res.list
+      })
     },
-		getAllClass() {
-			if (!this.$util.isEmpty(this.itemClassList)) {
-				return this.itemClassList
-			}
-			this.$service.itemClass.getAllClass().then((res) => {
-				this.itemClassList = res.list
-			})
-		},
     confirmFn () {
       if (this.checkList.length == 0) {
         this.$message.warning('请选择花材')
         return false
       }
-      if(this.sonClassId == 0){
+      if (this.sonClassId == 0) {
         this.$message.warning('请选择分类')
         return false
       }
-      this.$emit('confirm', {list:this.checkList,classId:this.sonClassId})
+      this.$emit('confirm', { list: this.checkList, classId: this.sonClassId })
     },
     resetForm () {
       this.$emit('cancel');
     },
-    selectItem(row){
+    selectItem (row) {
       console.log(1212121121)
       console.log(row)
-                //已经选过
-                if(row.select == 2){
-                  return false
-                }
-               let index = this.checkList.findIndex(e => e.id == row.id)
-               if(index === -1){
-                this.checkList = [row,...this.checkList]
-               }else{
-          this.checkList.splice(index,1)
-               }
+      //已经选过
+      if (row.select == 2) {
+        return false
+      }
+      let index = this.checkList.findIndex(e => e.id == row.id)
+      if (index === -1) {
+        this.checkList = [row, ...this.checkList]
+      } else {
+        this.checkList.splice(index, 1)
+      }
     },
     onLoad ({ ctx, app }) {
 
@@ -198,11 +259,11 @@ export default {
               align: 'center'
             }
           ],
-					on: {
-						'row-click': (row, column) => {
+          on: {
+            'row-click': (row, column) => {
               this.selectItem(row)
-						}
-					},
+            }
+          },
           // 操作列
           op: {
             visible: false // 是否显示