{"remainingRequest":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/views/marketing/broadcast/room/importGoods.vue?vue&type=script&lang=js","dependencies":[{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/views/marketing/broadcast/room/importGoods.vue","mtime":1701742078555},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport { liveGoodsListApi } from '@/api/marketing';\nexport default {\n  name: 'importGoods',\n  data() {\n    return {\n      keywords: '',\n      tableForm: {\n        page: 1,\n        limit: 20,\n        reviewStatus: 4,\n        keywords: '',\n      },\n      tableData: {\n        data: [],\n        total: 0,\n      },\n      multipleSelectionAll: [],\n      multipleSelection: [],\n      listLoading: false,\n      idKey: 'id',\n    };\n  },\n  mounted() {\n    this.getList();\n  },\n  methods: {\n    handleSelectionChange(val) {\n      this.multipleSelection = val;\n      setTimeout(() => {\n        this.changePageCoreRecordData();\n        let data = [];\n        if (this.multipleSelectionAll.length) {\n          this.multipleSelectionAll.map((item) => {\n            data.push(item.goodsId);\n          });\n        }\n        this.$emit('getGoodList', data);\n      }, 50);\n    },\n    // 设置选中的方法\n    setSelectRow() {\n      if (!this.multipleSelectionAll || this.multipleSelectionAll.length <= 0) {\n        return;\n      }\n      // 标识当前行的唯一键的名称\n      let idKey = this.idKey;\n      let selectAllIds = [];\n      this.multipleSelectionAll.forEach((row) => {\n        selectAllIds.push(row[idKey]);\n      });\n      this.$refs.table.clearSelection();\n      for (var i = 0; i < this.tableData.data.length; i++) {\n        if (selectAllIds.indexOf(this.tableData.data[i][idKey]) >= 0) {\n          // 设置选中，记住table组件需要使用ref=\"table\"\n          this.$refs.table.toggleRowSelection(this.tableData.data[i], true);\n        }\n      }\n    },\n    // 记忆选择核心方法\n    changePageCoreRecordData() {\n      // 标识当前行的唯一键的名称\n      let idKey = this.idKey;\n      let that = this;\n      // 如果总记忆中还没有选择的数据，那么就直接取当前页选中的数据，不需要后面一系列计算\n      if (this.multipleSelectionAll.length <= 0) {\n        this.multipleSelectionAll = this.multipleSelection;\n        return;\n      }\n      // 总选择里面的key集合\n      let selectAllIds = [];\n      this.multipleSelectionAll.forEach((row) => {\n        selectAllIds.push(row[idKey]);\n      });\n      let selectIds = [];\n      // 获取当前页选中的id\n      this.multipleSelection.forEach((row) => {\n        selectIds.push(row[idKey]);\n        // 如果总选择里面不包含当前页选中的数据，那么就加入到总选择集合里\n        if (selectAllIds.indexOf(row[idKey]) < 0) {\n          that.multipleSelectionAll.push(row);\n        }\n      });\n      let noSelectIds = [];\n      // 得到当前页没有选中的id\n      this.tableData.data.forEach((row) => {\n        if (selectIds.indexOf(row[idKey]) < 0) {\n          noSelectIds.push(row[idKey]);\n        }\n      });\n      noSelectIds.forEach((id) => {\n        if (selectAllIds.indexOf(id) >= 0) {\n          for (let i = 0; i < that.multipleSelectionAll.length; i++) {\n            if (that.multipleSelectionAll[i][idKey] == id) {\n              // 如果总选择中有未被选中的，那么就删除这条\n              that.multipleSelectionAll.splice(i, 1);\n              break;\n            }\n          }\n        }\n      });\n    },\n    // 列表\n    getList(num) {\n      this.listLoading = true;\n      this.tableForm.page = num ? num : this.tableForm.page;\n      this.tableForm.keywords = encodeURIComponent(this.keywords);\n      liveGoodsListApi(this.tableForm)\n        .then((res) => {\n          this.tableData.data = res.list;\n          this.tableData.total = res.total;\n          this.$nextTick(function () {\n            this.setSelectRow(); //调用跨页选中方法\n          });\n          this.listLoading = false;\n        })\n        .catch((res) => {\n          this.listLoading = false;\n        });\n    },\n    pageChange(page) {\n      this.changePageCoreRecordData();\n      this.tableForm.page = page;\n      this.getList();\n    },\n    handleSizeChange(val) {\n      this.changePageCoreRecordData();\n      this.tableForm.limit = val;\n      this.getList();\n    },\n  },\n};\n",null]}