Ver código fonte

物资类 选择分类优化

yuedefeng 6 anos atrás
pai
commit
1bbc5fdd0e

+ 15 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/goodsaptitude.go

@@ -355,3 +355,18 @@ func (this *OilGoodsAptitudeController) GoodsChildList() {
 	this.Data["json"] = &datainfo
 	this.ServeJSON()
 }
+
+// @Title get 获取子类
+// @Description get SampleType by token
+// @Success 200 {object} sampletype.SampleType
+// @router /goodschildlistbypid/:parentid [get]
+func (this *OilGoodsAptitudeController) GoodsChildLisByParentId() {
+	ParentId := this.Ctx.Input.Param(":parentid")
+	sqlStr := "SELECT Id, `Code`, `Name`, concat(Code, '  ', Name) as CodeName, ParentId, (CASE WHEN length(Code)>=8 THEN '1' ELSE '0' END) as Leaf FROM OilGoodsAptitudeClass WHERE ParentId = '" + ParentId + "' AND DeletionStateCode = 0 order by Code"
+	svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
+	list, _ := svc.DBE.QueryString(sqlStr)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}

+ 28 - 38
src/dashoo.cn/frontend_web/src/components/oilsupplier/goodslist.vue

@@ -29,7 +29,7 @@
       <el-row :gutter="20" style="height: calc(100vh - 450px); overflow: auto;">
         <el-col :span="20">
           <el-tree highlight-current :expand-on-click-node="true" node-key="CodeName" :data="orgtreelist"
-            :props="orgtreeprops" ref="orgmanagetree" show-checkbox lazy @node-click="getChildrens">
+            :props="orgtreeprops" ref="orgmanagetree" show-checkbox lazy :load="getChildrens">
           </el-tree>
         </el-col>
       </el-row>
@@ -40,7 +40,7 @@
         </el-col>
       </el-row>
       <div slot="footer" class="dialog-footer">
-        <el-button size="mini" @click="visible = false">取 消</el-button>
+        <!--<el-button size="mini" @click="visible = false">取 消</el-button>-->
         <el-button type="primary" size="mini" @click="getChecklist()">确 定</el-button>
       </div>
     </el-dialog>
@@ -81,7 +81,8 @@
         orgtreeprops: {
           value: 'Id',
           label: 'CodeName',
-          children: 'children'
+          children: 'children',
+          isLeaf: 'Leaf'
         },
         checkList: [],
         Remark: '',
@@ -200,10 +201,10 @@
           .catch(() => {})
       },
       showDialog() {
-        this.getorgtreelist()
+        //this.getorgtreelist()
         this.goodsDialog = true
       },
-      getorgtreelist() {
+      /*getorgtreelist() {
         let _this = this
         this.$axios.get('goodsaptitude/goodsparentlist', {})
           .then(res => {
@@ -215,43 +216,32 @@
           .catch(err => {
             console.error(err)
           })
-      },
+      },*/
       //获取下一级所有分类
-      getChildrens(val) {
-        let _this = this
-        let Id = val.id
-        if (Id != _this.flagId) { //判断是否是第一次,若不相等则为第一次
-          this.$axios.get('goodsaptitude/goodschildlist/' + Id, {})
-            .then(res => {
-              //获取下一级所有级联数据
-              if (res.data.items) { //判断是否有数据
-                let tempList = []
-                tempList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Code,Name,CodeName')
-                //添加到上一级对应的选项中
-                for (let i = 0; i < _this.orgtreelist.length; i++) {
-                  if (_this.orgtreelist[i].id === Id) {
-                    _this.$set(_this.orgtreelist[i], 'children', tempList)
-                    break
-                  }
-                }
-              } else {
-                //修改上一级的children属性
-                for (let i = 0; i < _this.orgtreelist.length; i++) {
-                  if (_this.orgtreelist[i].id === Id) {
-                    _this.$set(_this.orgtreelist[i], 'children', '')
-                    break
-                  }
-                }
-              }
-              _this.flagId = Id
-            })
-            .catch(err => {
-              console.error(err)
-            })
+      getChildrens (val, resolve) {
+        let Id = 0
+        if (val.level === 0) {
+          Id = 0
+        } else {
+          Id = val.data.Id
         }
+        this.$axios.get('goodsaptitude/goodschildlistbypid/' + Id, {})
+          .then(res => {
+            if (!res.data.items || res.data.items.length <= 0) {
+              val.isLeaf = true
+              return resolve([])
+            }
+            for (let idx in res.data.items) {
+              res.data.items[idx].Leaf = res.data.items[idx].Leaf === '1' ? true : false
+            }
+            return resolve(res.data.items)
+          })
+          .catch(err => {
+            console.error(err)
+          })
       },
 
-      handleSizeChange(value) {
+      handleSizeChange (value) {
         this.size = value
         this.currentPage = 1
         this.initData()