From 0d12f252e439b429a9d935eb6fd6314960b28be7 Mon Sep 17 00:00:00 2001
From: 懒羊羊 <15939171744@163.com>
Date: 星期四, 14 十二月 2023 08:42:01 +0800
Subject: [PATCH] 选择框

---
 jcdm-ui/src/components/itemSelect/single.vue |  208 ++++++++++++++++++++++++++
 jcdm-ui/src/components/itemSelect/index.vue  |  223 +++++++++++++++++++++++++++
 2 files changed, 431 insertions(+), 0 deletions(-)

diff --git a/jcdm-ui/src/components/itemSelect/index.vue b/jcdm-ui/src/components/itemSelect/index.vue
new file mode 100644
index 0000000..282ae3f
--- /dev/null
+++ b/jcdm-ui/src/components/itemSelect/index.vue
@@ -0,0 +1,223 @@
+<template>
+  <el-dialog title="鐗╂枡浜у搧閫夋嫨"
+    v-if="showFlag"
+    :visible.sync="showFlag"
+    :modal= false
+    width="80%"
+    center
+  >
+    <el-row :gutter="20">
+      <!--鍒嗙被鏁版嵁-->
+      <el-col :span="4" :xs="24">
+        <div class="head-container">
+          <el-input
+            v-model="itemTypeName"
+            placeholder="璇疯緭鍏ュ垎绫诲悕绉�"
+            clearable
+            size="small"
+            prefix-icon="el-icon-search"
+            style="margin-bottom: 20px"
+          />
+        </div>
+        <div class="head-container">
+          <el-tree
+            :data="itemTypeOptions"
+            :props="defaultProps"
+            :expand-on-click-node="false"
+            :filter-node-method="filterNode"
+            ref="tree"
+            default-expand-all
+            @node-click="handleNodeClick"
+          />
+        </div>
+      </el-col>
+      <!--鐗╂枡鏁版嵁-->
+      <el-col :span="20" :xs="24">
+        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+          <el-form-item label="鐗╂枡缂栫爜" prop="itemCode">
+            <el-input
+              v-model="queryParams.itemCode"
+              placeholder="璇疯緭鍏ョ墿鏂欑紪鐮�"
+              clearable
+              style="width: 240px"
+              @keyup.enter.native="handleQuery"
+            />
+          </el-form-item>
+          <el-form-item label="鐗╂枡鍚嶇О" prop="itemName">
+            <el-input
+              v-model="queryParams.itemName"
+              placeholder="璇疯緭鍏ョ墿鏂欏悕绉�"
+              clearable
+              style="width: 240px"
+              @keyup.enter.native="handleQuery"
+            />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+          </el-form-item>
+        </el-form>
+        <el-table v-loading="loading" :data="itemList" @selection-change="handleSelectionChange">
+          <el-table-column type="selection" width="50" align="center" />
+          <el-table-column label="鐗╂枡缂栫爜" width = "120" align="center" key="itemCode" prop="itemCode" v-if="columns[0].visible" >
+          </el-table-column>
+          <el-table-column label="鐗╂枡鍚嶇О" min-width="120" align="left" key="itemName" prop="itemName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
+          <el-table-column label="瑙勬牸鍨嬪彿" align="left" key="specification" prop="specification" v-if="columns[2].visible" :show-overflow-tooltip="true" />
+          <el-table-column label="鍗曚綅" align="center" key="unitOfMeasure" prop="unitOfMeasure" v-if="columns[3].visible" :show-overflow-tooltip="true" />
+          <el-table-column label="鐗╂枡/浜у搧" align="center" key="itemOrProduct" prop="itemOrProduct" v-if="columns[4].visible" :show-overflow-tooltip="true" >
+            <template slot-scope="scope">
+              <dict-tag :options="dict.type.mes_item_product" :value="scope.row.itemOrProduct"/>
+            </template>
+          </el-table-column>
+          <el-table-column label="鎵�灞炲垎绫�" align="center" key="itemTypeName" prop="itemTypeName" v-if="columns[5].visible" width="120" />
+          <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" v-if="columns[6].visible" width="160">
+            <template slot-scope="scope">
+              <span>{{ parseTime(scope.row.createTime) }}</span>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <pagination
+          v-show="total>0"
+          :total="total"
+          :page.sync="queryParams.pageNum"
+          :limit.sync="queryParams.pageSize"
+          @pagination="getList"
+        />
+      </el-col>
+    </el-row>
+    <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="confirmSelect">纭� 瀹�</el-button>
+        <el-button @click="showFlag=false">鍙� 娑�</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { listMdItem, getMdItem, delMdItem, addMdItem, updateMdItem} from "@/api/mes/md/mdItem";
+import { listAllUnitmeasure} from "@/api/mes/md/unitmeasure";
+import {genCode} from "@/api/system/autocode/rule"
+import { getToken } from "@/utils/auth";
+import { treeselect } from "@/api/mes/md/itemtype";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+
+export default {
+  name: "MdItemSelect",
+  dicts: ['sys_yes_no','mes_item_product'],
+  components: { Treeselect },
+  data() {
+    return {
+      showFlag:false,
+
+      // 閫変腑鏁扮粍
+      ids: [],
+      selectedRows: [],
+      // 闈炲崟涓鐢�
+      single: true,
+      // 闈炲涓鐢�
+      multiple: true,
+      // 鏄剧ず鎼滅储鏉′欢
+      showSearch: true,
+      // 鎬绘潯鏁�
+      total: 0,
+      // 鐗╂枡浜у搧琛ㄦ牸鏁版嵁
+      itemList: null,
+      // 閮ㄩ棬鏍戦�夐」
+      itemTypeOptions: undefined,
+      // 閮ㄩ棬鍚嶇О
+      itemTypeName: undefined,
+      defaultProps: {
+        children: "children",
+        label: "label"
+      },
+      // 鏌ヨ鍙傛暟
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        itemCode: undefined,
+        itemName: undefined,
+        itemTypeId: 0
+      },
+      // 鍒椾俊鎭�
+      columns: [
+        { key: 0, label: `鐗╂枡/浜у搧缂栫爜`, visible: true },
+        { key: 1, label: `鐗╂枡/浜у搧鍚嶇О`, visible: true },
+        { key: 2, label: `瑙勬牸鍨嬪彿`, visible: true },
+        { key: 3, label: `鍗曚綅`, visible: true },
+        { key: 4, label: `鐗╂枡/浜у搧`, visible: true },
+        { key: 5, label: `鐗╂枡鍒嗙被`, visible: true },
+        { key: 6, label: `鍒涘缓鏃堕棿`, visible: true }
+      ]
+    };
+  },
+  watch: {
+    // 鏍规嵁鍚嶇О绛涢�夊垎绫绘爲
+    itemTypeName(val) {
+      this.$refs.tree.filter(val);
+    }
+  },
+  created() {
+    this.getList();
+    this.getTreeselect();
+  },
+  methods: {
+    /** 鏌ヨ鐗╂枡缂栫爜鍒楄〃 */
+    getList() {
+      this.loading = true;
+      listMdItem(this.queryParams).then(response => {
+          this.itemList = response.rows;
+          this.total = response.total;
+          this.loading = false;
+        }
+      );
+    },
+    /** 鏌ヨ鍒嗙被涓嬫媺鏍戠粨鏋� */
+    getTreeselect() {
+      treeselect().then(response => {
+        this.itemTypeOptions = response.data;
+      });
+    },
+    // 绛涢�夎妭鐐�
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.label.indexOf(value) !== -1;
+    },
+    // 鑺傜偣鍗曞嚮浜嬩欢
+    handleNodeClick(data) {
+      this.queryParams.itemTypeId = data.id;
+      this.handleQuery();
+    },
+    /** 鎼滅储鎸夐挳鎿嶄綔 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 閲嶇疆鎸夐挳鎿嶄綔 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 澶氶�夋閫変腑鏁版嵁
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.itemId);
+      this.single = selection.length != 1;
+      this.multiple = !selection.length;
+      this.selectedRows = selection;
+    },
+    //纭畾閫変腑
+    confirmSelect(){
+        if(this.ids ==[] || this.ids.length==0){
+            this.$notify({
+                title:'鎻愮ず',
+                type:'warning',
+                message: '璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�!'
+            });
+            return;
+        }
+        this.$emit('onSelected',this.selectedRows);
+        this.showFlag = false;
+    }
+  }
+};
+</script>
\ No newline at end of file
diff --git a/jcdm-ui/src/components/itemSelect/single.vue b/jcdm-ui/src/components/itemSelect/single.vue
new file mode 100644
index 0000000..d0f7426
--- /dev/null
+++ b/jcdm-ui/src/components/itemSelect/single.vue
@@ -0,0 +1,208 @@
+<template>
+  <el-dialog title="鐗╂枡浜у搧閫夋嫨"
+             v-if="showFlag"
+             :visible.sync="showFlag"
+             :modal= false
+             width="80%"
+             center
+  >
+    <el-row :gutter="20">
+      <!--鐗╂枡鏁版嵁-->
+      <el-col :span="24" :xs="24">
+        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+          <el-form-item label="鐗╂枡缂栫爜" prop="itemCode">
+            <el-input
+              v-model="queryParams.itemCode"
+              placeholder="璇疯緭鍏ョ墿鏂欑紪鐮�"
+              clearable
+              style="width: 240px"
+              @keyup.enter.native="handleQuery"
+            />
+          </el-form-item>
+          <el-form-item label="鐗╂枡鍚嶇О" prop="itemName">
+            <el-input
+              v-model="queryParams.itemName"
+              placeholder="璇疯緭鍏ョ墿鏂欏悕绉�"
+              clearable
+              style="width: 240px"
+              @keyup.enter.native="handleQuery"
+            />
+          </el-form-item>
+          <el-form-item style="float: right">
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+          </el-form-item>
+        </el-form>
+        <el-table border v-loading="loading" :data="itemList" @current-change="handleCurrent" @row-dblclick="handleRowDbClick">
+          <el-table-column width="50" align="center" >
+            <template v-slot="scope">
+              <el-radio v-model="selectedItemId" :label="scope.row.id" @change="handleRowChange(scope.row)">{{""}}</el-radio>
+            </template>
+          </el-table-column>
+          <el-table-column label="鐗╂枡缂栧彿" align="center" prop="materialCode">
+          </el-table-column>
+          <el-table-column label="鐗╂枡鍚嶇О" align="center" prop="materialName">
+          </el-table-column>
+          <el-table-column label="绉嶇被" align="center" prop="typeZ">
+          </el-table-column>
+          <el-table-column label="绫诲瀷" align="center" prop="typeL">
+          </el-table-column>
+          <el-table-column label="鍗曚綅" align="center" prop="unit">
+          </el-table-column>
+          <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
+          </el-table-column>
+          <el-table-column label="ERP瑙勬牸" align="center" prop="erpSpec">
+          </el-table-column>
+          <el-table-column label="鏁版嵁鏉ユ簮" align="center" prop="dataSource">
+          </el-table-column>
+          <el-table-column label="鐘舵��" align="center" prop="status">
+          </el-table-column>
+          <el-table-column label="鍘傚晢" align="center" prop="supplier">
+          </el-table-column>
+          <el-table-column label="澶囨敞" align="center" prop="remarks">
+          </el-table-column>
+        </el-table>
+
+        <pagination
+          v-show="total>0"
+          :total="total"
+          :page.sync="queryParams.pageNum"
+          :limit.sync="queryParams.pageSize"
+          @pagination="getList"
+        />
+      </el-col>
+    </el-row>
+    <div slot="footer" class="dialog-footer">
+      <el-button type="primary" @click="confirmSelect">纭� 瀹�</el-button>
+      <el-button @click="showFlag=false">鍙� 娑�</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { listMaterial, getMaterial, delMaterial, addMaterial, updateMaterial } from "@/api/main/bs/material/material";
+
+export default {
+  name: "MdItemSingle",
+  dicts: ['sys_yes_no','mes_item_product'],
+  data() {
+    return {
+      showFlag:false,
+      // 閫変腑鏁扮粍
+      selectedItemId: undefined,
+      selectedRows: undefined,
+      // 闈炲崟涓鐢�
+      single: true,
+      // 闈炲涓鐢�
+      multiple: true,
+      // 鏄剧ず鎼滅储鏉′欢
+      showSearch: true,
+      // 鎬绘潯鏁�
+      total: 0,
+      // 鐗╂枡浜у搧琛ㄦ牸鏁版嵁
+      itemList: null,
+      // 閮ㄩ棬鏍戦�夐」
+      itemTypeOptions: undefined,
+      // 閮ㄩ棬鍚嶇О
+      itemTypeName: undefined,
+      defaultProps: {
+        children: "children",
+        label: "label"
+      },
+      // 鏌ヨ鍙傛暟
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        itemCode: undefined,
+        itemName: undefined,
+        itemTypeId: 0
+      },
+      // 鍒椾俊鎭�
+      columns: [
+        { key: 0, label: `鐗╂枡/浜у搧缂栫爜`, visible: true },
+        { key: 1, label: `鐗╂枡/浜у搧鍚嶇О`, visible: true },
+        { key: 2, label: `瑙勬牸鍨嬪彿`, visible: true },
+        { key: 3, label: `鍗曚綅`, visible: true },
+        { key: 4, label: `鐗╂枡/浜у搧`, visible: true },
+        { key: 5, label: `鐗╂枡鍒嗙被`, visible: true },
+        { key: 6, label: `鍒涘缓鏃堕棿`, visible: true }
+      ]
+    };
+  },
+  watch: {
+    // 鏍规嵁鍚嶇О绛涢�夊垎绫绘爲
+    itemTypeName(val) {
+      this.$refs.tree.filter(val);
+    }
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    /** 鏌ヨ鐗╂枡缂栫爜鍒楄〃 */
+    getList() {
+      this.loading = true;
+      listMaterial(this.queryParams).then(response => {
+          this.itemList = response.rows;
+          this.total = response.total;
+          this.loading = false;
+        }
+      );
+    },
+    // 绛涢�夎妭鐐�
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.label.indexOf(value) !== -1;
+    },
+    // 鑺傜偣鍗曞嚮浜嬩欢
+    handleNodeClick(data) {
+      this.queryParams.itemTypeId = data.id;
+      this.handleQuery();
+    },
+    /** 鎼滅储鎸夐挳鎿嶄綔 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 閲嶇疆鎸夐挳鎿嶄綔 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    handleCurrent(row){
+      if(row){
+        this.selectedRows = row;
+      }
+    },
+    handleRowDbClick(row){
+      if(row){
+        this.selectedRows = row;
+        this.$emit('onSelected',this.selectedRows);
+        this.showFlag = false;
+      }
+    },
+    // 鍗曢�夐�変腑鏁版嵁
+    handleRowChange(row) {
+      debugger;
+      if(row){
+        this.selectedRows = row;
+      }
+    },
+    //纭畾閫変腑
+    confirmSelect(){
+      if(this.selectedItemId ==null || this.selectedItemId==0){
+        this.$notify({
+          title:'鎻愮ず',
+          type:'warning',
+          message: '璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�!'
+        });
+        return;
+      }
+      console.log(this.selectedRows)
+
+      this.$emit('onSelected',this.selectedRows);
+      this.showFlag = false;
+    }
+  }
+};
+</script>

--
Gitblit v1.9.3