Browse Source

2022-08-25

王克恕 2 years ago
parent
commit
a8e618f8cf

+ 448 - 447
imcs-bt-fe/imcs-bt-fe/imcs-ui/src/views/zuihou/productionresource/components/ProductMgr.vue

@@ -1,447 +1,448 @@
-<template>
-  <div class="app-container">
-    <el-dialog :close-on-click-modal="false" :close-on-press-escape="true" :title="title" :type="type"
-               :visible.sync="isVisible" width="75%" top="50px" v-el-drag-dialog>
-      <!--    添加修改删除-->
-      <el-row class="filter-container">
-        <el-col>
-          <span>
-        <el-button @click="add" class="filter-item" plain type="primary">
-        添加
-      </el-button>
-
-        <el-button @click="onSale" class="filter-item" plain type="primary">
-        上架
-      </el-button>
-
-        <el-button @click="outSale" class="filter-item" plain type="primary">
-        下架
-      </el-button>
-
-        <el-button @click="batchDelete" class="filter-item" plain type="primary">
-        删除
-      </el-button>
-      </span>
-        </el-col>
-      </el-row>
-
-
-      <el-table
-        :data="tableData"
-        :key="tableKey"
-        @selection-change="onSelectChange"
-        @cell-click="cellClick"
-        border fit row-key="id"
-        ref="table"
-        style="width: 100%;"
-        v-loading="loading">
-        <el-table-column :label="$t('bt.table.cateNo')" :show-overflow-tooltip="true" align="center" prop="key"
-                         width="50">
-          <template slot-scope="scope">
-            <div>
-              {{ scope.$index + (queryParams.current - 1) * queryParams.size + 1 }}
-            </div>
-          </template>
-        </el-table-column>
-        <el-table-column align="center" type="selection" width="50px" :reserve-selection="true"/>
-        <el-table-column :label="$t('bt.table.goodsName')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsName" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsName }}</span>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsPic')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsPic" width="">
-          <template slot-scope="scope">
-            <img :src="scope.row.goodsPic" min-width="70" height="70"/>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsCode')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsCode" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsCode }}</span>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsUnit')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsUnit" width="">
-          <template slot-scope="scope">
-            {{ scope.row.goodsUnit === '1' ? $t('bt.unit.bei') : '' }}
-            {{ scope.row.goodsUnit === '2' ? $t('bt.unit.jian') : '' }}
-            {{ scope.row.goodsUnit === '3' ? $t('bt.unit.ge') : '' }}
-            {{ scope.row.goodsUnit === '4' ? $t('bt.unit.bao') : '' }}
-            {{ scope.row.goodsUnit === '5' ? $t('bt.unit.fen') : '' }}
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsCateId')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsCateName" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsCateName }}</span>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsTag')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsTag" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsTag }}</span>
-          </template>
-        </el-table-column>
-
-        <el-table-column :label="$t('bt.table.goodsSpec')" :show-overflow-tooltip="true" align="center"
-                         prop="speList" width="">
-          <template slot-scope="scope">
-            <span v-for="item  in scope.row.speList" :key="item.id">{{ item.specName }} &#32, </span>
-          </template>
-        </el-table-column>
-
-        <el-table-column :label="$t('bt.table.goodsStatus')" :show-overflow-tooltip="true" align="center"
-                         prop="udStatus" width="">
-
-          <template slot-scope="scope">
-            {{ scope.row.udStatus === '1' ? $t("productionResource.goods.onSale") : '' }}
-            {{ scope.row.udStatus === '0' ? $t("productionResource.goods.underSale") : '' }}
-          </template>
-
-
-        </el-table-column>
-      </el-table>
-      <!--      <pagination-->
-      <!--        :limit.sync="queryParams.size"-->
-      <!--        :page.sync="queryParams.current"-->
-      <!--        :total="Number(tableData.total)"-->
-      <!--        @pagination="fetch"-->
-      <!--        v-show="tableData.total > 0"/>-->
-    </el-dialog>
-
-    <add-equ-goods
-      :dialog-visible="addGoodsDialog.isVisible"
-      :type="addGoodsDialog.type"
-      @close="addGoodsClose"
-      @success="addGoodsSuccess"
-      ref="addEquGoods"/>
-
-
-    <!--    <el-dialog-->
-    <!--      :close-on-click-modal="false"-->
-    <!--      :close-on-press-escape="true"-->
-    <!--      title="预览"-->
-    <!--      width="80%"-->
-    <!--      top="50px"-->
-    <!--      :visible.sync="preview.isVisible"-->
-    <!--      v-el-drag-dialog>-->
-    <!--      <el-scrollbar>-->
-    <!--        <div v-html="preview.context"></div>-->
-    <!--      </el-scrollbar>-->
-    <!--    </el-dialog>-->
-  </div>
-
-
-</template>
-
-<script>
-import Pagination from "@/components/Pagination";
-import ParameterEdit from "../../goods/goodsManage/Index";
-import parameterApi from "@/api/Parameter.js";
-import ResourceBusinessApi from "@/api/ResourceBusiness.js";
-import ProductionresourceApi from "@/api/resourceProductMgr/productionResourcesMgr";
-import elDragDialog from '@/directive/el-drag-dialog'
-import {downloadFile, initDicts, initEnums, initQueryParams} from '@/utils/commons'
-import qs from 'qs'
-import addEquGoods from "@/views/zuihou/productionresource/components/addEquGoods";
-
-export default {
-  name: "productMgr",
-  directives: {elDragDialog},
-  components: {Pagination, ParameterEdit, addEquGoods},
-  props: {
-    dialogVisible: {
-      type: Boolean,
-      default: false
-    },
-    type: {
-      type: String,
-      default: "add"
-    },
-  },
-  filters: {},
-  data() {
-    return {
-      statusOptions: [{
-        value: '0',
-        label: '冻结'
-      }, {
-        value: '1',
-        label: '启用'
-      }],
-      dialog: {
-        isVisible: false,
-        type: "addEquGoods"
-      },
-
-      addGoodsDialog: {
-        isVisible: false,
-        type: "addEquGoods"
-      },
-
-      preview: {
-        isVisible: false,
-        context: ''
-      },
-      fileImport: {
-        isVisible: false,
-        type: "import",
-        action: `${process.env.VUE_APP_BASE_API}/authority/parameter/import`
-      },
-      tableKey: 0,
-      queryParams: initQueryParams({
-        model: {}
-      }),
-      selection: [],
-      loading: false,
-      tableData: [],
-      goodsIds: [],
-      equId: '',
-      uploadIds: []
-    };
-  },
-  computed: {
-    isVisible: {
-      get() {
-        return this.dialogVisible;
-      },
-      set() {
-        this.close();
-        this.reset();
-      }
-    },
-    title() {
-      return '设备销售产品管理';
-    }
-  },
-  watch: {},
-  mounted() {
-  },
-  methods: {
-    initWidth() {
-      this.screenWidth = document.body.clientWidth;
-      if (this.screenWidth < 991) {
-        return "90%";
-      } else if (this.screenWidth < 1400) {
-        return "45%";
-      } else {
-        return "800px";
-      }
-    },
-    editClose() {
-      this.dialog.isVisible = false;
-    },
-    addGoodsClose() {
-      this.addGoodsDialog.isVisible = false;
-    },
-    addGoodsSuccess() {
-      this.getEquGoods(this.equId)
-    },
-    onSelectChange(selection) {
-      this.selection = selection;
-    },
-    search() {
-      this.getEquGoods(this.equId);
-    },
-    add() {
-      console.log("准备添加商品了")
-      this.addGoodsDialog.type = "addEquGoods";
-      this.addGoodsDialog.isVisible = true;
-      this.$refs.addEquGoods.getAllGoods({
-        'equId': this.equId,
-        enums: this.enums,
-        dicts: this.dicts,
-        goodsIds: this.goodsIds
-      });
-    },
-
-    close() {
-      this.$emit("close");
-    },
-    reset() {
-      this.queryParams = initQueryParams({});
-      this.$refs.table.clearSort();
-      this.$refs.table.clearFilter();
-      this.equId = "";
-      this.goodsIds = [];
-      this.uploadIds = [];
-      this.$refs.table.clearSelection();
-      this.search();
-    },
-
-    equGoodsMgr(equId) {
-      this.equId = equId;
-      console.log("变没变" + this.equId)
-      this.getEquGoods(equId);
-    },
-    singleDelete(row) {
-      this.$refs.table.clearSelection();
-      this.$refs.table.toggleRowSelection(row, true);
-      this.batchDelete();
-    },
-    batchDelete() {
-      if (!this.selection.length) {
-        this.$message({
-          message: this.$t("tips.noDataSelected"),
-          type: "warning"
-        });
-        return;
-      }
-      this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), {
-        confirmButtonText: this.$t("common.confirm"),
-        cancelButtonText: this.$t("common.cancel"),
-        type: "warning"
-      })
-        .then(() => {
-          const ids = this.selection.map(u => u.id);
-          this.delete(ids);
-        })
-        .catch(() => {
-          this.clearSelections();
-        });
-    },
-
-    onSale() {
-      if (!this.selection.length) {
-        this.$message({
-          message: this.$t("tips.noDataSelected"),
-          type: "warning"
-        });
-        return;
-      }
-      this.$confirm(this.$t("bt.common.onSale"), this.$t("common.tips"), {
-        confirmButtonText: this.$t("common.confirm"),
-        cancelButtonText: this.$t("common.cancel"),
-        type: "warning"
-      })
-        .then(() => {
-          this.selection.map(u => {
-            this.uploadIds.push({"id": u.id, "udStatus": "1"})
-          })
-          this.uploadStatus(this.uploadIds)
-        })
-        .catch(() => {
-          this.clearSelections();
-        });
-    },
-
-    outSale() {
-      if (!this.selection.length) {
-        this.$message({
-          message: this.$t("tips.noDataSelected"),
-          type: "warning"
-        });
-        return;
-      }
-      this.$confirm(this.$t("bt.common.outSale"), this.$t("common.tips"), {
-        confirmButtonText: this.$t("common.confirm"),
-        cancelButtonText: this.$t("common.cancel"),
-        type: "warning"
-      })
-        .then(() => {
-          this.selection.map(u => {
-            this.uploadIds.push({"id": u.id, "udStatus": "0"})
-
-          })
-          this.uploadStatus(this.uploadIds)
-        })
-        .catch(() => {
-          this.clearSelections();
-        });
-    },
-
-
-    clearSelections() {
-      this.$refs.table.clearSelection();
-    },
-    delete(ids) {
-      ProductionresourceApi.deleteEquGoods(ids).then(response => {
-        const res = response.data;
-        if (res.isSuccess) {
-          this.$message({
-            message: this.$t("tips.deleteSuccess"),
-            type: "success"
-          });
-        }
-        this.getEquGoods(this.equId);
-      });
-    },
-
-
-    uploadStatus(data) {
-      ProductionresourceApi.updateGoodsStu(data).then(response => {
-        const res = response.data;
-        if (res.isSuccess) {
-          this.$message({
-            message: this.$t("tips.updateSuccess"),
-            type: "success"
-          });
-        }
-        this.getEquGoods(this.equId);
-      });
-    },
-
-
-    editOne() {
-      if (!this.selection.length) {
-        this.$message({
-          message: this.$t("tips.unSelected"),
-          type: "warning"
-        })
-        return
-      }
-      if (this.selection.length > 1) {
-        this.$message({
-          message: this.$t("tips.mustOne"),
-          type: "warning"
-        })
-        return
-      }
-      this.edit(this.selection[0]);
-    },
-    choose() {
-      this.dialog.type = "choose";
-      this.dialog.isVisible = true;
-    },
-    edit(row) {
-      this.$refs.edit.setProductionresource(row)
-      this.dialog.type = "edit";
-      this.dialog.isVisible = true;
-    },
-
-    getEquGoods(equId) {
-      this.loading = true;
-      ResourceBusinessApi.getEquGoods({'equId': equId}).then(response => {
-        let res = response.data
-        if (res.isSuccess) {
-          this.tableData = res.data;
-          this.goodsIds = [];
-          this.tableData.forEach(item => {
-            this.goodsIds.push(item.goodsId)
-          })
-        }
-      }).finally(() => this.loading = false);
-    },
-
-    cellClick(row, column) {
-      if (column['columnKey'] === "operation") {
-        return;
-      }
-      let flag = false;
-      this.selection.forEach((item) => {
-        if (item.id === row.id) {
-          flag = true;
-          this.$refs.table.toggleRowSelection(row);
-        }
-      })
-
-      if (!flag) {
-        this.$refs.table.toggleRowSelection(row, true);
-      }
-    }
-  }
-};
-</script>
-<style lang="scss" scoped></style>
+<template>
+  <div class="app-container">
+    <el-dialog :close-on-click-modal="false" :close-on-press-escape="true" :title="title" :type="type"
+               :visible.sync="isVisible" width="75%" top="50px" v-el-drag-dialog>
+      <!--    添加修改删除-->
+      <el-row class="filter-container">
+        <el-col>
+          <span>
+        <el-button @click="add" class="filter-item" plain type="primary">
+        添加
+      </el-button>
+
+        <el-button @click="onSale" class="filter-item" plain type="primary">
+        上架
+      </el-button>
+
+        <el-button @click="outSale" class="filter-item" plain type="primary">
+        下架
+      </el-button>
+
+        <el-button @click="batchDelete" class="filter-item" plain type="primary">
+        删除
+      </el-button>
+      </span>
+        </el-col>
+      </el-row>
+
+
+      <el-table
+        :data="tableData"
+        :key="tableKey"
+        @selection-change="onSelectChange"
+        @cell-click="cellClick"
+        border fit row-key="id"
+        ref="table"
+        style="width: 100%;"
+        v-loading="loading">
+        <el-table-column :label="$t('bt.table.cateNo')" :show-overflow-tooltip="true" align="center" prop="key"
+                         width="50">
+          <template slot-scope="scope">
+            <div>
+              {{ scope.$index + (queryParams.current - 1) * queryParams.size + 1 }}
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" type="selection" width="50px" :reserve-selection="true"/>
+        <el-table-column :label="$t('bt.table.goodsName')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsName" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsName }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsPic')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsPic" width="">
+          <template slot-scope="scope">
+            <img :src="scope.row.goodsPic" min-width="70" height="70"/>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsCode')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsCode" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsCode }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsUnit')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsUnit" width="">
+          <template slot-scope="scope">
+            {{ scope.row.goodsUnit === '1' ? $t('bt.unit.bei') : '' }}
+            {{ scope.row.goodsUnit === '2' ? $t('bt.unit.jian') : '' }}
+            {{ scope.row.goodsUnit === '3' ? $t('bt.unit.ge') : '' }}
+            {{ scope.row.goodsUnit === '4' ? $t('bt.unit.bao') : '' }}
+            {{ scope.row.goodsUnit === '5' ? $t('bt.unit.fen') : '' }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsCateId')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsCateName" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsCateName }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsTag')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsTag" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsTag }}</span>
+          </template>
+        </el-table-column>
+
+        <el-table-column :label="$t('bt.table.goodsSpec')" :show-overflow-tooltip="true" align="center"
+                         prop="speList" width="">
+          <template slot-scope="scope">
+            <span v-for="item  in scope.row.speList" :key="item.id">{{ item.specName }} &#32, </span>
+          </template>
+        </el-table-column>
+
+        <el-table-column :label="$t('bt.table.goodsStatus')" :show-overflow-tooltip="true" align="center"
+                         prop="udStatus" width="">
+
+          <template slot-scope="scope">
+            {{ scope.row.udStatus === '1' ? $t("productionResource.goods.onSale") : '' }}
+            {{ scope.row.udStatus === '0' ? $t("productionResource.goods.underSale") : '' }}
+          </template>
+
+
+        </el-table-column>
+      </el-table>
+      <!--      <pagination-->
+      <!--        :limit.sync="queryParams.size"-->
+      <!--        :page.sync="queryParams.current"-->
+      <!--        :total="Number(tableData.total)"-->
+      <!--        @pagination="fetch"-->
+      <!--        v-show="tableData.total > 0"/>-->
+    </el-dialog>
+
+    <add-equ-goods
+      :dialog-visible="addGoodsDialog.isVisible"
+      :type="addGoodsDialog.type"
+      @close="addGoodsClose"
+      @success="addGoodsSuccess"
+      ref="addEquGoods"/>
+
+
+    <!--    <el-dialog-->
+    <!--      :close-on-click-modal="false"-->
+    <!--      :close-on-press-escape="true"-->
+    <!--      title="预览"-->
+    <!--      width="80%"-->
+    <!--      top="50px"-->
+    <!--      :visible.sync="preview.isVisible"-->
+    <!--      v-el-drag-dialog>-->
+    <!--      <el-scrollbar>-->
+    <!--        <div v-html="preview.context"></div>-->
+    <!--      </el-scrollbar>-->
+    <!--    </el-dialog>-->
+  </div>
+
+
+</template>
+
+<script>
+import Pagination from "@/components/Pagination";
+import ParameterEdit from "../../goods/goodsManage/Index";
+import parameterApi from "@/api/Parameter.js";
+import ResourceBusinessApi from "@/api/ResourceBusiness.js";
+import ProductionresourceApi from "@/api/resourceProductMgr/productionResourcesMgr";
+import elDragDialog from '@/directive/el-drag-dialog'
+import {downloadFile, initDicts, initEnums, initQueryParams} from '@/utils/commons'
+import qs from 'qs'
+import addEquGoods from "@/views/zuihou/productionresource/components/addEquGoods";
+
+export default {
+  name: "productMgr",
+  directives: {elDragDialog},
+  components: {Pagination, ParameterEdit, addEquGoods},
+  props: {
+    dialogVisible: {
+      type: Boolean,
+      default: false
+    },
+    type: {
+      type: String,
+      default: "add"
+    },
+  },
+  filters: {},
+  data() {
+    return {
+      statusOptions: [{
+        value: '0',
+        label: '冻结'
+      }, {
+        value: '1',
+        label: '启用'
+      }],
+      dialog: {
+        isVisible: false,
+        type: "addEquGoods"
+      },
+
+      addGoodsDialog: {
+        isVisible: false,
+        type: "addEquGoods"
+      },
+
+      preview: {
+        isVisible: false,
+        context: ''
+      },
+      fileImport: {
+        isVisible: false,
+        type: "import",
+        action: `${process.env.VUE_APP_BASE_API}/authority/parameter/import`
+      },
+      tableKey: 0,
+      queryParams: initQueryParams({
+        model: {}
+      }),
+      selection: [],
+      loading: false,
+      tableData: [],
+      goodsIds: [],
+      equId: '',
+      uploadIds: []
+    };
+  },
+  computed: {
+    isVisible: {
+      get() {
+        return this.dialogVisible;
+      },
+      set() {
+        this.close();
+        this.reset();
+      }
+    },
+    title() {
+      return '设备销售产品管理';
+    }
+  },
+  watch: {},
+  mounted() {
+  },
+  methods: {
+    initWidth() {
+      this.screenWidth = document.body.clientWidth;
+      if (this.screenWidth < 991) {
+        return "90%";
+      } else if (this.screenWidth < 1400) {
+        return "45%";
+      } else {
+        return "800px";
+      }
+    },
+    editClose() {
+      this.dialog.isVisible = false;
+    },
+    addGoodsClose() {
+      this.addGoodsDialog.isVisible = false;
+    },
+    addGoodsSuccess() {
+      this.getEquGoods(this.equId)
+    },
+    onSelectChange(selection) {
+      this.selection = selection;
+    },
+    search() {
+      this.getEquGoods(this.equId);
+    },
+    add() {
+      console.log("准备添加商品了")
+      this.addGoodsDialog.type = "addEquGoods";
+      this.addGoodsDialog.isVisible = true;
+      // this.$refs.addEquGoods.getAllGoods({
+      this.$refs.addEquGoods.setInitData({
+        equId: this.equId,
+        enums: this.enums,
+        dicts: this.dicts,
+        goodsIds: this.goodsIds
+      });
+    },
+
+    close() {
+      this.$emit("close");
+    },
+    reset() {
+      this.queryParams = initQueryParams({});
+      this.$refs.table.clearSort();
+      this.$refs.table.clearFilter();
+      this.equId = "";
+      this.goodsIds = [];
+      this.uploadIds = [];
+      this.$refs.table.clearSelection();
+      this.search();
+    },
+
+    equGoodsMgr(equId) {
+      this.equId = equId;
+      console.log("变没变" + this.equId)
+      this.getEquGoods(equId);
+    },
+    singleDelete(row) {
+      this.$refs.table.clearSelection();
+      this.$refs.table.toggleRowSelection(row, true);
+      this.batchDelete();
+    },
+    batchDelete() {
+      if (!this.selection.length) {
+        this.$message({
+          message: this.$t("tips.noDataSelected"),
+          type: "warning"
+        });
+        return;
+      }
+      this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), {
+        confirmButtonText: this.$t("common.confirm"),
+        cancelButtonText: this.$t("common.cancel"),
+        type: "warning"
+      })
+        .then(() => {
+          const ids = this.selection.map(u => u.id);
+          this.delete(ids);
+        })
+        .catch(() => {
+          this.clearSelections();
+        });
+    },
+
+    onSale() {
+      if (!this.selection.length) {
+        this.$message({
+          message: this.$t("tips.noDataSelected"),
+          type: "warning"
+        });
+        return;
+      }
+      this.$confirm(this.$t("bt.common.onSale"), this.$t("common.tips"), {
+        confirmButtonText: this.$t("common.confirm"),
+        cancelButtonText: this.$t("common.cancel"),
+        type: "warning"
+      })
+        .then(() => {
+          this.selection.map(u => {
+            this.uploadIds.push({"id": u.id, "udStatus": "1"})
+          })
+          this.uploadStatus(this.uploadIds)
+        })
+        .catch(() => {
+          this.clearSelections();
+        });
+    },
+
+    outSale() {
+      if (!this.selection.length) {
+        this.$message({
+          message: this.$t("tips.noDataSelected"),
+          type: "warning"
+        });
+        return;
+      }
+      this.$confirm(this.$t("bt.common.outSale"), this.$t("common.tips"), {
+        confirmButtonText: this.$t("common.confirm"),
+        cancelButtonText: this.$t("common.cancel"),
+        type: "warning"
+      })
+        .then(() => {
+          this.selection.map(u => {
+            this.uploadIds.push({"id": u.id, "udStatus": "0"})
+
+          })
+          this.uploadStatus(this.uploadIds)
+        })
+        .catch(() => {
+          this.clearSelections();
+        });
+    },
+
+
+    clearSelections() {
+      this.$refs.table.clearSelection();
+    },
+    delete(ids) {
+      ProductionresourceApi.deleteEquGoods(ids).then(response => {
+        const res = response.data;
+        if (res.isSuccess) {
+          this.$message({
+            message: this.$t("tips.deleteSuccess"),
+            type: "success"
+          });
+        }
+        this.getEquGoods(this.equId);
+      });
+    },
+
+
+    uploadStatus(data) {
+      ProductionresourceApi.updateGoodsStu(data).then(response => {
+        const res = response.data;
+        if (res.isSuccess) {
+          this.$message({
+            message: this.$t("tips.updateSuccess"),
+            type: "success"
+          });
+        }
+        this.getEquGoods(this.equId);
+      });
+    },
+
+
+    editOne() {
+      if (!this.selection.length) {
+        this.$message({
+          message: this.$t("tips.unSelected"),
+          type: "warning"
+        })
+        return
+      }
+      if (this.selection.length > 1) {
+        this.$message({
+          message: this.$t("tips.mustOne"),
+          type: "warning"
+        })
+        return
+      }
+      this.edit(this.selection[0]);
+    },
+    choose() {
+      this.dialog.type = "choose";
+      this.dialog.isVisible = true;
+    },
+    edit(row) {
+      this.$refs.edit.setProductionresource(row)
+      this.dialog.type = "edit";
+      this.dialog.isVisible = true;
+    },
+
+    getEquGoods(equId) {
+      this.loading = true;
+      ResourceBusinessApi.getEquGoods({'equId': equId}).then(response => {
+        let res = response.data
+        if (res.isSuccess) {
+          this.tableData = res.data;
+          this.goodsIds = [];
+          this.tableData.forEach(item => {
+            this.goodsIds.push(item.goodsId)
+          })
+        }
+      }).finally(() => this.loading = false);
+    },
+
+    cellClick(row, column) {
+      if (column['columnKey'] === "operation") {
+        return;
+      }
+      let flag = false;
+      this.selection.forEach((item) => {
+        if (item.id === row.id) {
+          flag = true;
+          this.$refs.table.toggleRowSelection(row);
+        }
+      })
+
+      if (!flag) {
+        this.$refs.table.toggleRowSelection(row, true);
+      }
+    }
+  }
+};
+</script>
+<style lang="scss" scoped></style>

+ 436 - 435
imcs-bt-fe/imcs-bt-fe/imcs-ui/src/views/zuihou/productionresource/components/addEquGoods.vue

@@ -1,435 +1,436 @@
-<template>
-  <el-dialog
-    :close-on-click-modal="false"
-    :close-on-press-escape="true"
-    :title="title"
-    :type="type"
-    :visible.sync="isVisible"
-    :width="width"
-    top="50px">
-    <div class="dialog-footer" slot="footer">
-      <el-button @click="isVisible = false" plain type="warning">
-        {{ $t("common.cancel") }}
-      </el-button>
-      <el-button @click="save" plain type="primary">
-        {{ $t("common.confirm") }}
-      </el-button>
-    </div>
-
-
-    <div class="app-container">
-      <div class="filter-container">
-        <!--搜索条件-->
-        <span>
-              {{ $t("bt.searchForm.goodsName") }}:
-            <el-input
-              class="filter-item search-item"
-              v-model="queryParams.model.goodsName"/>
-          </span>
-        <span>
-          {{ $t("bt.searchForm.goodsStatus") }}:
-        <el-select v-model="queryParams.model.goodsStatus" placeholder="请选择">
-            <el-option
-              v-for="item in statusOptions"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value">
-            </el-option>
-        </el-select>
-        </span>
-        <!--搜索、重置-->
-        <span>
-        <el-button @click="search" class="filter-item" plain type="primary">
-        {{ $t("table.search") }}
-      </el-button>
-      <el-button @click="reset" class="filter-item" plain type="warning">
-        {{ $t("table.reset") }}
-      </el-button>
-      </span>
-      </div>
-
-      <el-table
-        :data="tableData.records"
-        :key="tableKey"
-        @filter-change="filterChange"
-        @selection-change="onSelectChange"
-        @sort-change="sortChange"
-        @cell-click="cellClick"
-        border fit row-key="id"
-        ref="table"
-        style="width: 100%;"
-        v-loading="loading">
-        <el-table-column :label="$t('bt.table.cateNo')" :show-overflow-tooltip="true" align="center" prop="key"
-                         width="50">
-          <template slot-scope="scope">
-            <div>
-              {{ scope.$index + (queryParams.current - 1) * queryParams.size + 1 }}
-            </div>
-          </template>
-        </el-table-column>
-        <el-table-column align="center" type="selection" width="50px" :reserve-selection="true"/>
-        <el-table-column :label="$t('bt.table.goodsName')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsName" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsName }}</span>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsPic')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsPic" width="">
-          <template slot-scope="scope">
-            <img :src="scope.row.goodsPic" min-width="70" height="70"/>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsCode')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsCode" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsCode }}</span>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsUnit')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsUnit" width="">
-          <template slot-scope="scope">
-            {{ scope.row.goodsUnit === '1' ? $t('bt.unit.bei') : '' }}
-            {{ scope.row.goodsUnit === '2' ? $t('bt.unit.jian') : '' }}
-            {{ scope.row.goodsUnit === '3' ? $t('bt.unit.ge') : '' }}
-            {{ scope.row.goodsUnit === '4' ? $t('bt.unit.bao') : '' }}
-            {{ scope.row.goodsUnit === '5' ? $t('bt.unit.fen') : '' }}
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsCateId')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsCateId" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsCateName }}</span>
-          </template>
-        </el-table-column>
-        <el-table-column :label="$t('bt.table.goodsTag')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsTag" width="">
-          <template slot-scope="scope">
-            <span>{{ scope.row.goodsTag }}</span>
-          </template>
-        </el-table-column>
-
-        <el-table-column :label="$t('bt.table.goodsSpec')" :show-overflow-tooltip="true" align="center"
-                         prop="goodsSpec" width="">
-          <template slot-scope="scope">
-            <span v-for="item in scope.row.goodsSpec" :key="item.id">{{ item.specName }} &#32, </span>
-          </template>
-        </el-table-column>
-      </el-table>
-      <Pagination
-        :limit.sync="queryParams.size"
-        :page.sync="queryParams.current"
-        :total="Number(tableData.total)"
-        @pagination="getAllGoods"
-        v-show="tableData.total > 0"/>
-    </div>
-  </el-dialog>
-
-
-</template>
-<script>
-import elDragDialog from '@/directive/el-drag-dialog'
-import productionResourceApi from "@/api/Productionresource.js"
-import {regionData} from 'element-china-area-data'
-
-import placeApi from "@/api/Place.js"
-import orgApi from "@/api/Org.js"
-import GoodsApi from "@/api/goods/Goods";
-import {initQueryParams} from "@/utils/commons";
-import Pagination from "@/components/Pagination";
-import {number} from "echarts";
-import userApi from "@/api/User";
-
-export default {
-  name: "addEquGoods",
-  directives: {elDragDialog},
-  components: {Pagination},
-  props: {
-    dialogVisible: {
-      type: Boolean,
-      default: false
-    },
-    type: {
-      type: String,
-      default: "add"
-    },
-    // equ: {
-    //   type: [Number, String],
-    //   default: 0
-    // }
-  },
-  data() {
-    return {
-      loading: false,
-      statusOptions: [{
-        value: '0',
-        label: '冻结'
-      }, {
-        value: '1',
-        label: '启用'
-      }],
-      tableKey: 0,
-      confirmDisabled: false,
-      equGoods: this.initEquGoods(),
-      screenWidth: 0,
-      width: this.initWidth(),
-      // 枚举
-      enums: {},
-      // 字典
-      dicts: {},
-      queryParams: initQueryParams({
-        model: {}
-      }),
-      tableData: {
-        total: 0
-      },
-      existGoodsIds: [],
-      selection: [],
-      equAndGoods: [],
-      equId: '',
-    };
-  },
-  computed: {
-    isVisible: {
-      get() {
-        return this.dialogVisible;
-      },
-      set() {
-        this.close();
-        this.reset();
-      }
-    },
-    title() {
-      return "新增商品";
-    }
-  },
-  watch: {},
-  mounted() {
-    window.onresize = () => {
-      return (() => {
-        this.width = this.initWidth();
-      })();
-    };
-  },
-  created() {
-    // this.getEnterpriseList();
-  },
-  methods: {
-
-    initEquGoods() {
-      return {
-        id: "",
-        secretKey: '',
-        tenantId: '',
-        moduleId: '',
-        areaId: '',
-        placeId: '',
-        name: '',
-        location: '',
-        code: '',
-        status: '',
-        onlineStatus: '',
-        remark: '',
-        ip: '',
-        port: '',
-        areaIds: [],
-        latitude: '',
-        longtitude: '',
-      };
-    },
-    onSelectChange(selection) {
-      this.selection = selection;
-    },
-    sortChange(val) {
-      this.queryParams.sort = val.prop;
-      this.queryParams.order = val.order;
-      if (this.queryParams.sort) {
-        this.search();
-      }
-    },
-    filterChange(filters) {
-      for (const key in filters) {
-        if (key.includes('.')) {
-          const val = {};
-          val[key.split('.')[1]] = filters[key][0];
-          this.queryParams.model[key.split('.')[0]] = val;
-        } else {
-          this.queryParams.model[key] = filters[key][0]
-        }
-      }
-      this.search()
-    },
-    cellClick(row, column) {
-      if (column['columnKey'] === "operation") {
-        return;
-      }
-      let flag = false;
-      this.selection.forEach((item) => {
-        if (item.id === row.id) {
-          flag = true;
-          this.$refs.table.toggleRowSelection(row);
-        }
-      })
-
-      if (!flag) {
-        this.$refs.table.toggleRowSelection(row, true);
-      }
-    },
-    search() {
-      this.getAllGoods({
-        ...this.queryParams
-      });
-    },
-
-
-    getAllGoods(params = {}) {
-      console.log("还没开始勾选商品时的selection===" + this.selection)
-      this.loading = true;
-      //赋值
-      this.equId = params['equId'];
-      this.existGoodsIds = params.goodsIds;
-      console.log("已经添加的商品" + JSON.stringify(this.existGoodsIds))
-
-      if (this.queryParams.timeRange) {
-        this.queryParams.map.createTime_st = this.queryParams.timeRange[0];
-        this.queryParams.map.createTime_ed = this.queryParams.timeRange[1];
-      }
-
-      this.queryParams.current = params.current ? params.current : this.queryParams.current;
-      this.queryParams.size = params.size ? params.size : this.queryParams.size;
-      this.queryParams.model.equId = params['equId'];
-
-
-      GoodsApi.page(this.queryParams).then(response => {
-        const res = response.data;
-        if (res.isSuccess) {
-          this.tableData = res.data;
-        }
-      }).finally(() => this.loading = false);
-    },
-
-    initWidth() {
-      this.screenWidth = document.body.clientWidth;
-      if (this.screenWidth < 991) {
-        return "90%";
-      } else if (this.screenWidth < 1400) {
-        return "45%";
-      } else {
-        return "800px";
-      }
-    },
-    close() {
-      this.$emit("close");
-    },
-    reset() {
-      // 先清除校验,再清除表单,不然有奇怪的bug
-      // this.$refs.form.clearValidate();
-      // this.$refs.form.resetFields();
-      this.confirmDisabled = false;
-      this.queryParams = initQueryParams({});
-      this.$refs.table.clearSort();
-      this.$refs.table.clearFilter();
-      this.$refs.table.clearSelection();
-      this.equId = "";
-      this.existGoodsIds = [];
-      this.equAndGoods = [];
-
-      this.search();
-    },
-    submitForm() {
-      const vm = this;
-      this.$refs.form.validate(valid => {
-        if (valid) {
-          vm.editSubmit();
-        } else {
-          return false;
-        }
-      });
-    },
-    editSubmit() {
-      const vm = this;
-      if (vm.type === "edit") {
-        vm.update();
-      } else {
-        vm.save();
-      }
-    },
-    save() {
-      const vm = this;
-      vm.confirmDisabled = true;
-
-      if (!this.selection.length) {
-        this.$message({
-          message: this.$t("tips.noDataSelected"),
-          type: "warning"
-        });
-        return;
-      }
-      // this.equAndGoods.equId = this.equId;
-
-      for (var i = 0; i < this.selection.length; i++) {
-        if (!this.existGoodsIds.includes(this.selection[i].id)) {
-          console.log("排除已经添加过的商品")
-          this.equAndGoods.push({"equId": this.equId, "goodsId": this.selection[i].id, "udStatus": '0'})
-        }
-
-      }
-
-      // this.selection.forEach(v =>
-      //   this.equAndGoods.push({"equId": this.equId, "goodsId": v.id, "udStatus": '1'})
-      // );
-      // let aaa = this.equId;
-      // productionResourceApi.saveEquGoods({'equId': this.equId, 'egList': this.equAndGoods}).then(response => {
-      //   const res = response.data;
-      //   // this.selection = [];
-      //   if (res.isSuccess) {
-      //     vm.isVisible = false;
-      //     vm.$message({
-      //       message: vm.$t("tips.createSuccess"),
-      //       type: "success"
-      //     });
-      //     vm.$emit("success", aaa);
-      //     console.log("this.equId====" + aaa)
-      //   }
-      // }).finally(() => vm.confirmDisabled = false, this.selection = []).catch();
-
-
-      productionResourceApi.saveEquGoods(this.equAndGoods).then(response => {
-        const res = response.data;
-        if (res.isSuccess) {
-          vm.isVisible = false;
-          vm.$message({
-            message: vm.$t("tips.createSuccess"),
-            type: "success"
-          });
-          vm.$emit("success");
-        }
-      });
-
-
-    },
-
-    clearSelections() {
-      this.$refs.table.clearSelection();
-    },
-
-
-    update() {
-      const vm = this;
-      vm.confirmDisabled = true;
-      productionResourceApi.update(this.productionResource).then(response => {
-        const res = response.data;
-        if (res.isSuccess) {
-          vm.isVisible = false;
-          vm.$message({
-            message: this.$t("tips.updateSuccess"),
-            type: "success"
-          });
-          vm.$emit("success");
-        }
-      }).finally(() => vm.confirmDisabled = false);
-    }
-  }
-};
-</script>
-<style lang="scss" scoped></style>
+<template>
+  <el-dialog
+    :close-on-click-modal="false"
+    :close-on-press-escape="true"
+    :title="title"
+    :type="type"
+    :visible.sync="isVisible"
+    :width="width"
+    top="50px">
+    <div class="dialog-footer" slot="footer">
+      <el-button @click="isVisible = false" plain type="warning">
+        {{ $t("common.cancel") }}
+      </el-button>
+      <el-button @click="save" plain type="primary">
+        {{ $t("common.confirm") }}
+      </el-button>
+    </div>
+
+
+    <div class="app-container">
+      <div class="filter-container">
+        <!--搜索条件-->
+        <span>
+              {{ $t("bt.searchForm.goodsName") }}:
+            <el-input
+              class="filter-item search-item"
+              v-model="queryParams.model.goodsName"/>
+          </span>
+        <span>
+          {{ $t("bt.searchForm.goodsStatus") }}:
+        <el-select v-model="queryParams.model.goodsStatus" placeholder="请选择">
+            <el-option
+              v-for="item in statusOptions"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value">
+            </el-option>
+        </el-select>
+        </span>
+        <!--搜索、重置-->
+        <span>
+        <el-button @click="search" class="filter-item" plain type="primary">
+        {{ $t("table.search") }}
+      </el-button>
+      <el-button @click="reset" class="filter-item" plain type="warning">
+        {{ $t("table.reset") }}
+      </el-button>
+      </span>
+      </div>
+
+      <el-table
+        :data="tableData.records"
+        :key="tableKey"
+        @filter-change="filterChange"
+        @selection-change="onSelectChange"
+        @sort-change="sortChange"
+        @cell-click="cellClick"
+        border fit row-key="id"
+        ref="table"
+        style="width: 100%;"
+        v-loading="loading">
+        <el-table-column :label="$t('bt.table.cateNo')" :show-overflow-tooltip="true" align="center" prop="key"
+                         width="50">
+          <template slot-scope="scope">
+            <div>
+              {{ scope.$index + (queryParams.current - 1) * queryParams.size + 1 }}
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" type="selection" width="50px" :reserve-selection="true"/>
+        <el-table-column :label="$t('bt.table.goodsName')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsName" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsName }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsPic')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsPic" width="">
+          <template slot-scope="scope">
+            <img :src="scope.row.goodsPic" min-width="70" height="70"/>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsCode')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsCode" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsCode }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsUnit')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsUnit" width="">
+          <template slot-scope="scope">
+            {{ scope.row.goodsUnit === '1' ? $t('bt.unit.bei') : '' }}
+            {{ scope.row.goodsUnit === '2' ? $t('bt.unit.jian') : '' }}
+            {{ scope.row.goodsUnit === '3' ? $t('bt.unit.ge') : '' }}
+            {{ scope.row.goodsUnit === '4' ? $t('bt.unit.bao') : '' }}
+            {{ scope.row.goodsUnit === '5' ? $t('bt.unit.fen') : '' }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsCateId')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsCateId" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsCateName }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('bt.table.goodsTag')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsTag" width="">
+          <template slot-scope="scope">
+            <span>{{ scope.row.goodsTag }}</span>
+          </template>
+        </el-table-column>
+
+        <el-table-column :label="$t('bt.table.goodsSpec')" :show-overflow-tooltip="true" align="center"
+                         prop="goodsSpec" width="">
+          <template slot-scope="scope">
+            <span v-for="item in scope.row.goodsSpec" :key="item.id">{{ item.specName }} &#32, </span>
+          </template>
+        </el-table-column>
+      </el-table>
+      <Pagination
+        :limit.sync="queryParams.size"
+        :page.sync="queryParams.current"
+        :total="Number(tableData.total)"
+        @pagination="getAllGoods"
+        v-show="tableData.total > 0"/>
+    </div>
+  </el-dialog>
+
+
+</template>
+<script>
+import elDragDialog from '@/directive/el-drag-dialog'
+import productionResourceApi from "@/api/Productionresource.js"
+import {regionData} from 'element-china-area-data'
+
+import placeApi from "@/api/Place.js"
+import orgApi from "@/api/Org.js"
+import GoodsApi from "@/api/goods/Goods";
+import {initQueryParams} from "@/utils/commons";
+import Pagination from "@/components/Pagination";
+import {number} from "echarts";
+import userApi from "@/api/User";
+
+export default {
+  name: "addEquGoods",
+  directives: {elDragDialog},
+  components: {Pagination},
+  props: {
+    dialogVisible: {
+      type: Boolean,
+      default: false
+    },
+    type: {
+      type: String,
+      default: "add"
+    },
+    // equ: {
+    //   type: [Number, String],
+    //   default: 0
+    // }
+  },
+  data() {
+    return {
+      loading: false,
+      statusOptions: [{
+        value: '0',
+        label: '冻结'
+      }, {
+        value: '1',
+        label: '启用'
+      }],
+      tableKey: 0,
+      confirmDisabled: false,
+      equGoods: this.initEquGoods(),
+      screenWidth: 0,
+      width: this.initWidth(),
+      // 枚举
+      enums: {},
+      // 字典
+      dicts: {},
+      queryParams: initQueryParams({
+        model: {}
+      }),
+      tableData: {
+        total: 0
+      },
+      existGoodsIds: [],
+      selection: [],
+      equAndGoods: [],
+      equId: '',
+    };
+  },
+  computed: {
+    isVisible: {
+      get() {
+        return this.dialogVisible;
+      },
+      set() {
+        this.close();
+        this.reset();
+      }
+    },
+    title() {
+      return "新增商品";
+    }
+  },
+  watch: {},
+  mounted() {
+    window.onresize = () => {
+      return (() => {
+        this.width = this.initWidth();
+      })();
+    };
+  },
+  created() {
+    // this.getEnterpriseList();
+  },
+  methods: {
+
+    initEquGoods() {
+      return {
+        id: "",
+        secretKey: '',
+        tenantId: '',
+        moduleId: '',
+        areaId: '',
+        placeId: '',
+        name: '',
+        location: '',
+        code: '',
+        status: '',
+        onlineStatus: '',
+        remark: '',
+        ip: '',
+        port: '',
+        areaIds: [],
+        latitude: '',
+        longtitude: '',
+      };
+    },
+    onSelectChange(selection) {
+      this.selection = selection;
+    },
+    sortChange(val) {
+      this.queryParams.sort = val.prop;
+      this.queryParams.order = val.order;
+      if (this.queryParams.sort) {
+        this.search();
+      }
+    },
+    filterChange(filters) {
+      for (const key in filters) {
+        if (key.includes('.')) {
+          const val = {};
+          val[key.split('.')[1]] = filters[key][0];
+          this.queryParams.model[key.split('.')[0]] = val;
+        } else {
+          this.queryParams.model[key] = filters[key][0]
+        }
+      }
+      this.search()
+    },
+    cellClick(row, column) {
+      if (column['columnKey'] === "operation") {
+        return;
+      }
+      let flag = false;
+      this.selection.forEach((item) => {
+        if (item.id === row.id) {
+          flag = true;
+          this.$refs.table.toggleRowSelection(row);
+        }
+      })
+
+      if (!flag) {
+        this.$refs.table.toggleRowSelection(row, true);
+      }
+    },
+    search() {
+      this.getAllGoods({
+        ...this.queryParams
+      });
+    },
+    
+    /**
+     * 初始化页面的-函数
+     * */
+    setInitData(data) {
+    	//赋值
+    	this.equId = data.equId;
+    	this.existGoodsIds = data.goodsIds;
+    	// 加载-分页列表数据
+    	this.search();
+    },
+
+    getAllGoods(params = {}) {
+      this.loading = true;
+      if (this.queryParams.timeRange) {
+        this.queryParams.map.createTime_st = this.queryParams.timeRange[0];
+        this.queryParams.map.createTime_ed = this.queryParams.timeRange[1];
+      }
+      this.queryParams.current = params.current ? params.current : this.queryParams.current;
+      this.queryParams.size = params.size ? params.size : this.queryParams.size;
+      this.queryParams.model.equId = this.equId;
+      GoodsApi.page(this.queryParams).then(response => {
+        const res = response.data;
+        if (res.isSuccess) {
+          this.tableData = res.data;
+        }
+      }).finally(() => this.loading = false);
+    },
+
+    initWidth() {
+      this.screenWidth = document.body.clientWidth;
+      if (this.screenWidth < 991) {
+        return "90%";
+      } else if (this.screenWidth < 1400) {
+        return "45%";
+      } else {
+        return "800px";
+      }
+    },
+    close() {
+      this.$emit("close");
+    },
+    reset() {
+      // 先清除校验,再清除表单,不然有奇怪的bug
+      // this.$refs.form.clearValidate();
+      // this.$refs.form.resetFields();
+      this.confirmDisabled = false;
+      this.queryParams = initQueryParams({});
+      this.$refs.table.clearSort();
+      this.$refs.table.clearFilter();
+      this.$refs.table.clearSelection();
+      this.equId = "";
+      this.existGoodsIds = [];
+      this.equAndGoods = [];
+
+      this.search();
+    },
+    submitForm() {
+      const vm = this;
+      this.$refs.form.validate(valid => {
+        if (valid) {
+          vm.editSubmit();
+        } else {
+          return false;
+        }
+      });
+    },
+    editSubmit() {
+      const vm = this;
+      if (vm.type === "edit") {
+        vm.update();
+      } else {
+        vm.save();
+      }
+    },
+    save() {
+      const vm = this;
+      vm.confirmDisabled = true;
+
+      if (!this.selection.length) {
+        this.$message({
+          message: this.$t("tips.noDataSelected"),
+          type: "warning"
+        });
+        return;
+      }
+      // this.equAndGoods.equId = this.equId;
+
+      for (var i = 0; i < this.selection.length; i++) {
+        if (!this.existGoodsIds.includes(this.selection[i].id)) {
+          console.log("排除已经添加过的商品")
+          this.equAndGoods.push({"equId": this.equId, "goodsId": this.selection[i].id, "udStatus": '0'})
+        }
+
+      }
+
+      // this.selection.forEach(v =>
+      //   this.equAndGoods.push({"equId": this.equId, "goodsId": v.id, "udStatus": '1'})
+      // );
+      // let aaa = this.equId;
+      // productionResourceApi.saveEquGoods({'equId': this.equId, 'egList': this.equAndGoods}).then(response => {
+      //   const res = response.data;
+      //   // this.selection = [];
+      //   if (res.isSuccess) {
+      //     vm.isVisible = false;
+      //     vm.$message({
+      //       message: vm.$t("tips.createSuccess"),
+      //       type: "success"
+      //     });
+      //     vm.$emit("success", aaa);
+      //     console.log("this.equId====" + aaa)
+      //   }
+      // }).finally(() => vm.confirmDisabled = false, this.selection = []).catch();
+
+
+      productionResourceApi.saveEquGoods(this.equAndGoods).then(response => {
+        const res = response.data;
+        if (res.isSuccess) {
+          vm.isVisible = false;
+          vm.$message({
+            message: vm.$t("tips.createSuccess"),
+            type: "success"
+          });
+          vm.$emit("success");
+        }
+      });
+
+
+    },
+
+    clearSelections() {
+      this.$refs.table.clearSelection();
+    },
+
+
+    update() {
+      const vm = this;
+      vm.confirmDisabled = true;
+      productionResourceApi.update(this.productionResource).then(response => {
+        const res = response.data;
+        if (res.isSuccess) {
+          vm.isVisible = false;
+          vm.$message({
+            message: this.$t("tips.updateSuccess"),
+            type: "success"
+          });
+          vm.$emit("success");
+        }
+      }).finally(() => vm.confirmDisabled = false);
+    }
+  }
+};
+</script>
+<style lang="scss" scoped></style>