charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/views/other/commonDialog/SelectCommonDialog.vue
@@ -10,15 +10,28 @@
      <div slot="title" class="tac drawerHeader">{{ editCommonConfig.title }}</div>
      <div class="bg-view">
        <div class="query-bg">
        <div style="display: flex;justify-content: space-between">
          <div class="query-bg" style="margin: 10px">
          <el-input
            v-model="bomParams.keyword"
            placeholder="搜索产品名称,编码等关键词"
            style="width: 60%; margin-right: 10px"
          ></el-input>
          <el-button type="primary" @click="searchClick">查询</el-button>
        </div>
          <div style="margin: 10px">
            <el-cascader
                    v-model="categoryIds"
                    collapse-tags
                    placeholder="请选择产品类别"
                    :options="productCategoryList"
                    :props="props"
                    clearable
                    @change="getProductList"
            ></el-cascader>
          </div>
        </div>
        <TableCommonView
          :warehouseId="warehouseId"
          class="bg-list"
          ref="tableListRef"
          :loading="loading"
@@ -52,12 +65,18 @@
</template>
<script>
import { getProductList } from "@/api/product/product"
import { getProductList,locationProductListApi } from "@/api/product/product"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getProductCategoryList } from '@/api/product/productCategory'
import { getTreeData } from '@/common/untils/index';
export default {
  name: "EditSelCommonDialog",
  mixins: [pageMixin],
  props: {
      warehouseId:{
        type:Number,
        default:0
      },
    editCommonConfig: {
      type: Object,
      default: () => {
@@ -82,6 +101,12 @@
  computed: {},
  data() {
    return {
        categoryIds:[],
        props:{
            label:'name',
            value:'id',
            multiple:true
        },
      dialogWidth: "42rem",
      pagerCount: 5,
      editConfig: this.editCommonConfig,
@@ -94,12 +119,14 @@
        page: 1,
        pageSize: 10,
        types: ["原材料", "半成品", "成品"]
      }
      },
      productCategoryList:[]
    }
  },
  created() {
    this.setTable()
    this.getData()
    this.setTable();
    this.getData();
    this.queryProductCategoryList();
  },
  methods: {
    setTable() {
@@ -121,7 +148,15 @@
      this.tableList.allcol = allcol
    },
    setTopTableColumn(showcol) {
      let tableColumn = [
          {
              label: "产品编码",
              prop: "id",
              min: 110,
              isShowColumn: true,
              default: true
          },
        {
          label: "产品名称",
          prop: "name",
@@ -129,9 +164,22 @@
          default: true,
          isClick: true
        },
          /*{
              label: "产品类别",
              prop: "categoryName",
              isShowColumn: true,
              default: true
          },*/
        {
          label: "产品编码",
          prop: "id",
              label: "位置",
              prop: "locationName",
              min: 110,
              isShowColumn: true,
              default: true
          },
          {
              label: "数量",
              prop: "amount",
          min: 110,
          isShowColumn: true,
          default: true
@@ -160,6 +208,12 @@
    getSelectArray(val) {
      this.selectArray = val
    },
      async queryProductCategoryList(){
        const {code ,data}=await getProductCategoryList({page:0,pageSize:0});
        if(code===200){
            this.productCategoryList=getTreeData(data);
        }
      }  ,
    saveClick() {
      this.$emit("getSelectArray", this.selectArray)
      this.editConfig.editVisible = false
@@ -175,7 +229,11 @@
    async getProductList() {
      this.bomParams.page = this.pagerOptions.currPage ? this.pagerOptions.currPage : 1
      this.bomParams.pageSize = this.pagerOptions.pageSize ? this.pagerOptions.pageSize : 15
      let params = JSON.parse(JSON.stringify(this.bomParams))
      let params = JSON.parse(JSON.stringify(this.bomParams));
      const routerParams=this.$route.query;
      const ids=[...new Set(this.categoryIds.flat(Infinity))];
       params.categoryIds=ids;
        if(routerParams.workType==1){
      await getProductList(params).then((res) => {
        console.log(res.data)
        if (res.code === 200) {
@@ -188,6 +246,30 @@
        }
        this.loading = false
      })
      }else{
          params={
              "keyword": "",
              "page":this.pagerOptions.currPage ? this.pagerOptions.currPage : 1,
              "pageSize": this.pagerOptions.pageSize ? this.pagerOptions.pageSize : 15,
              "warehouseId": routerParams.warehouseId?parseInt(routerParams.warehouseId):this.warehouseId
          };
          params.categoryIds=ids;
          locationProductListApi(params).then(res=>{
              if (res.code === 200) {
                  if (res.data) {
                      this.tableList.tableInfomation = res.data || []
                      this.tableList.tableInfomation.map(item=>{
                          item.locationName=item.location.name;
                      });
                      this.pagerOptions.totalCount = res.total ? res.total : 0
                  } else {
                      this.tableList.tableInfomation = []
                  }
              }
              this.loading = false
          });
      }
    },
    handleClose() {
      this.editConfig.editVisible = false