|  | @@ -0,0 +1,244 @@
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <div>
 | 
	
		
			
				|  |  | +    <el-dialog
 | 
	
		
			
				|  |  | +      width="1000px"
 | 
	
		
			
				|  |  | +      title="添加商品"
 | 
	
		
			
				|  |  | +      :visible.sync="lookVisible"
 | 
	
		
			
				|  |  | +      :before-close="onClose"
 | 
	
		
			
				|  |  | +      append-to-body
 | 
	
		
			
				|  |  | +    >
 | 
	
		
			
				|  |  | +      <div>
 | 
	
		
			
				|  |  | +        <el-form :inline="true" :model="searchForm">
 | 
	
		
			
				|  |  | +          <el-form-item>
 | 
	
		
			
				|  |  | +            <el-input
 | 
	
		
			
				|  |  | +              v-model.trim="searchForm.search"
 | 
	
		
			
				|  |  | +              clearable
 | 
	
		
			
				|  |  | +              @keyup.enter.native="search"
 | 
	
		
			
				|  |  | +              placeholder="商品名称"
 | 
	
		
			
				|  |  | +            ></el-input>
 | 
	
		
			
				|  |  | +          </el-form-item>
 | 
	
		
			
				|  |  | +          <el-form-item>
 | 
	
		
			
				|  |  | +            <el-button @click="search" type="primary">搜索</el-button>
 | 
	
		
			
				|  |  | +            <el-button @click="onReSet" type="danger">重置</el-button>
 | 
	
		
			
				|  |  | +          </el-form-item>
 | 
	
		
			
				|  |  | +        </el-form>
 | 
	
		
			
				|  |  | +        <div class="tableWrap">
 | 
	
		
			
				|  |  | +          <el-table
 | 
	
		
			
				|  |  | +            style="width: 100%"
 | 
	
		
			
				|  |  | +            :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
 | 
	
		
			
				|  |  | +            :data="tableList"
 | 
	
		
			
				|  |  | +            @selection-change="handleSelectionChange"
 | 
	
		
			
				|  |  | +            @select="onTableSelect"
 | 
	
		
			
				|  |  | +            ref="multipleSelection"
 | 
	
		
			
				|  |  | +          >
 | 
	
		
			
				|  |  | +            <el-table-column type="selection" width="55"> </el-table-column>
 | 
	
		
			
				|  |  | +            <el-table-column
 | 
	
		
			
				|  |  | +              align="center"
 | 
	
		
			
				|  |  | +              prop="id"
 | 
	
		
			
				|  |  | +              label="商品编号"
 | 
	
		
			
				|  |  | +            ></el-table-column>
 | 
	
		
			
				|  |  | +            <el-table-column
 | 
	
		
			
				|  |  | +              align="center"
 | 
	
		
			
				|  |  | +              prop="name"
 | 
	
		
			
				|  |  | +              label="商品名称"
 | 
	
		
			
				|  |  | +            ></el-table-column>
 | 
	
		
			
				|  |  | +            <el-table-column align="center" prop="originalPrice" label="原价">
 | 
	
		
			
				|  |  | +              <template slot-scope="scope">
 | 
	
		
			
				|  |  | +                <div>
 | 
	
		
			
				|  |  | +                  {{ scope.row.originalPrice | moneyFormat(true) }}
 | 
	
		
			
				|  |  | +                </div>
 | 
	
		
			
				|  |  | +              </template>
 | 
	
		
			
				|  |  | +            </el-table-column>
 | 
	
		
			
				|  |  | +            <el-table-column align="center" prop="currentPrice" label="直播价">
 | 
	
		
			
				|  |  | +              <template slot-scope="scope">
 | 
	
		
			
				|  |  | +                <div>
 | 
	
		
			
				|  |  | +                  {{ scope.row.currentPrice | moneyFormat(true) }}
 | 
	
		
			
				|  |  | +                </div>
 | 
	
		
			
				|  |  | +              </template>
 | 
	
		
			
				|  |  | +            </el-table-column>
 | 
	
		
			
				|  |  | +            <el-table-column
 | 
	
		
			
				|  |  | +              align="center"
 | 
	
		
			
				|  |  | +              prop="stockCount"
 | 
	
		
			
				|  |  | +              label="库存"
 | 
	
		
			
				|  |  | +            ></el-table-column>
 | 
	
		
			
				|  |  | +          </el-table>
 | 
	
		
			
				|  |  | +          <pagination
 | 
	
		
			
				|  |  | +            sync
 | 
	
		
			
				|  |  | +            :total.sync="rules.total"
 | 
	
		
			
				|  |  | +            :page.sync="rules.page"
 | 
	
		
			
				|  |  | +            :limit.sync="rules.limit"
 | 
	
		
			
				|  |  | +            :page-sizes="rules.page_size"
 | 
	
		
			
				|  |  | +            @pagination="getList"
 | 
	
		
			
				|  |  | +          />
 | 
	
		
			
				|  |  | +        </div>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <div slot="footer" class="dialog-footer">
 | 
	
		
			
				|  |  | +        <el-button type="primary" @click="submit">确 定</el-button>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +    </el-dialog>
 | 
	
		
			
				|  |  | +  </div>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +<script>
 | 
	
		
			
				|  |  | +import { getGroupList, addGroupMessageList } from "../api";
 | 
	
		
			
				|  |  | +import { getLiveGoodsMapperList } from "@/views/liveShopManger/api";
 | 
	
		
			
				|  |  | +import pagination from "@/components/Pagination/index";
 | 
	
		
			
				|  |  | +export default {
 | 
	
		
			
				|  |  | +  name: "eidtPostMsg",
 | 
	
		
			
				|  |  | +  components: { pagination },
 | 
	
		
			
				|  |  | +  data() {
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      searchForm: {
 | 
	
		
			
				|  |  | +        search: "",
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      tableList: [],
 | 
	
		
			
				|  |  | +      organList: [],
 | 
	
		
			
				|  |  | +      rules: {
 | 
	
		
			
				|  |  | +        // 分页规则
 | 
	
		
			
				|  |  | +        limit: 10, // 限制显示条数
 | 
	
		
			
				|  |  | +        page: 1, // 当前页
 | 
	
		
			
				|  |  | +        total: 0, // 总条数
 | 
	
		
			
				|  |  | +        page_size: [10, 20, 40, 50], // 选择限制显示条数
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      addMuiscVisible: false,
 | 
	
		
			
				|  |  | +      multipleSelection: [],
 | 
	
		
			
				|  |  | +      chioseIdList: [],
 | 
	
		
			
				|  |  | +      isNewPage: false,
 | 
	
		
			
				|  |  | +      lookVisible: false,
 | 
	
		
			
				|  |  | +      activeRow: { sendFlag: false },
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  mounted() {},
 | 
	
		
			
				|  |  | +  methods: {
 | 
	
		
			
				|  |  | +    async getList() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        const res = await getLiveGoodsMapperList({
 | 
	
		
			
				|  |  | +          ...this.searchForm,
 | 
	
		
			
				|  |  | +          page: this.rules.page,
 | 
	
		
			
				|  |  | +          rows: this.rules.limit,
 | 
	
		
			
				|  |  | +          imSendGroupMessageId: this.activeRow.id,
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        this.tableList = res.data.rows;
 | 
	
		
			
				|  |  | +        this.rules.total = res.data.total;
 | 
	
		
			
				|  |  | +        let idList = this.chioseIdList.map((group) => {
 | 
	
		
			
				|  |  | +          return group.id;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        this.isNewPage = true;
 | 
	
		
			
				|  |  | +        this.$nextTick(() => {
 | 
	
		
			
				|  |  | +          this.tableList.forEach((course) => {
 | 
	
		
			
				|  |  | +            if (idList.indexOf(course.id) != -1) {
 | 
	
		
			
				|  |  | +              this.$refs.multipleSelection.toggleRowSelection(course, true);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          this.isNewPage = false;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      } catch (e) {
 | 
	
		
			
				|  |  | +        console.log(e);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    search() {
 | 
	
		
			
				|  |  | +      this.rules.page = 1;
 | 
	
		
			
				|  |  | +      this.getList();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onReSet() {
 | 
	
		
			
				|  |  | +      this.searchForm.search = "";
 | 
	
		
			
				|  |  | +      this.clearCom();
 | 
	
		
			
				|  |  | +      this.search();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    async submit() {
 | 
	
		
			
				|  |  | +      if (!this.chioseIdList || this.chioseIdList.length <= 0) {
 | 
	
		
			
				|  |  | +        this.$message.error("请至少选择一件商品");
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        let idList = this.chioseIdList
 | 
	
		
			
				|  |  | +          .map((group) => {
 | 
	
		
			
				|  |  | +            return group.id;
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +          .join(",");
 | 
	
		
			
				|  |  | +        const res = await addGroupMessageList({
 | 
	
		
			
				|  |  | +          groupIds: idList,
 | 
	
		
			
				|  |  | +          imSendGroupMessageId: this.activeRow.id,
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        this.$message.success("添加成功");
 | 
	
		
			
				|  |  | +        this.$emit("getList");
 | 
	
		
			
				|  |  | +        this.onClose();
 | 
	
		
			
				|  |  | +      } catch (e) {
 | 
	
		
			
				|  |  | +        console.log(e);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      // 开始  addGroupMessageList
 | 
	
		
			
				|  |  | +      /**
 | 
	
		
			
				|  |  | +       *
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +       */
 | 
	
		
			
				|  |  | +      console.log(this.chioseIdList);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    handleSelectionChange(val) {
 | 
	
		
			
				|  |  | +      if (val.length > 0) {
 | 
	
		
			
				|  |  | +        this.chioseIdList = this.chioseIdList.concat(val);
 | 
	
		
			
				|  |  | +        this.chioseIdList = this.$helpers.lodash.uniqBy(
 | 
	
		
			
				|  |  | +          this.chioseIdList,
 | 
	
		
			
				|  |  | +          "id"
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        if (this.isNewPage) return;
 | 
	
		
			
				|  |  | +        let idList = this.chioseIdList.map((group) => {
 | 
	
		
			
				|  |  | +          return group.id;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        this.$nextTick(() => {
 | 
	
		
			
				|  |  | +          let tableIdList = [];
 | 
	
		
			
				|  |  | +          this.tableList.forEach((group) => {
 | 
	
		
			
				|  |  | +            tableIdList.push(group.id);
 | 
	
		
			
				|  |  | +            if (idList.indexOf(group.id) != -1) {
 | 
	
		
			
				|  |  | +              this.$refs.multipleSelection.toggleRowSelection(group, false);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          this.chioseIdList = this.$helpers.lodash.remove(
 | 
	
		
			
				|  |  | +            this.chioseIdList,
 | 
	
		
			
				|  |  | +            function (item) {
 | 
	
		
			
				|  |  | +              return tableIdList.indexOf(item.id) == -1;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +          if (this.chioseIdList.length <= 0) {
 | 
	
		
			
				|  |  | +            this.clearCom();
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    clearCom() {
 | 
	
		
			
				|  |  | +      this.chioseIdList = [];
 | 
	
		
			
				|  |  | +      this.$refs.multipleSelection.clearSelection();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onTableSelect(rows, row) {
 | 
	
		
			
				|  |  | +      let idList = this.chioseIdList.map((group) => {
 | 
	
		
			
				|  |  | +        return group.id;
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +      if (idList.indexOf(row.id) != -1) {
 | 
	
		
			
				|  |  | +        this.chioseIdList.splice(idList.indexOf(row.id), 1);
 | 
	
		
			
				|  |  | +        if (this.chioseIdList.length <= 0) {
 | 
	
		
			
				|  |  | +          this.clearCom();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onClose() {
 | 
	
		
			
				|  |  | +      this.clearCom();
 | 
	
		
			
				|  |  | +      this.lookVisible = false;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    openDioag(row) {
 | 
	
		
			
				|  |  | +      this.activeRow = row;
 | 
	
		
			
				|  |  | +      this.lookVisible = true;
 | 
	
		
			
				|  |  | +      console.log(row);
 | 
	
		
			
				|  |  | +      this.getList();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +</script>
 | 
	
		
			
				|  |  | +<style lang="scss" scoped>
 | 
	
		
			
				|  |  | +.w100 {
 | 
	
		
			
				|  |  | +  width: 100%;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.btnWrap {
 | 
	
		
			
				|  |  | +  justify-content: flex-start;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</style>
 |