haoxuan
2023-08-29 87f7f7a7588e926c6535eea2910ae98ca4101994
采购 添加 列表编辑 子段补充,联调
10个文件已修改
481 ■■■■■ 已修改文件
src/api/data.js 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/purchaseManage/purchase.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appsidebar/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/makepager/BomDialog.vue 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/makepager/TableCommonView.vue 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/DetailSupplier.vue 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/components/AddPurchase.vue 143 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/index.vue 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/quality/index.vue 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/returned/index.vue 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/data.js
@@ -17,10 +17,43 @@
    id:4,
  },
]
// 质检单状态
const qualityStatus=[
  {
    name:'待质检',
    id:1,
  },
  {
    name:'已完成',
    id:2,
  }
]
// 退货单状态
const returnedStatus=[
  {
    name:'待发货',
    id:1,
  },
  {
    name:'待签收',
    id:2,
  },
  {
    name:'待发货',
    id:3,
  },
  {
    name:'已完成',
    id:4,
  },
]
export const getDataByType = type => {
  if(type =='purchaseStatus'){
    return purchaseStatus;
  }else if(type=='qualityStatus'){
    return qualityStatus;
  }else if(type=='returnedStatus'){
    return returnedStatus;
  }
}
src/api/purchaseManage/purchase.js
@@ -95,3 +95,19 @@
      data
    })
  }
// 新建采购类型
export function savePurchaseType(data) {
  return request({
    url: "/api/purchase/purchaseType",
    method: "post",
    data
  })
}
// 获取采购类型
export function getPurchaseType(data) {
  return request({
    url: "/api/purchase/purchaseTypeList",
    method: "get",
    data
  })
}
src/components/layout/components/appsidebar/index.vue
@@ -30,7 +30,7 @@
          </template>
          <el-menu-item index="/purchaseManage/purchase">采购订单</el-menu-item>
          <el-menu-item index="/purchaseManage/quality">采购质检单</el-menu-item>
          <el-menu-item index="/purchaseManage/warehouse">采购入库单</el-menu-item>
          <!-- <el-menu-item index="/purchaseManage/warehouse">采购入库单</el-menu-item> -->
          <el-menu-item index="/purchaseManage/returned">采购退货单</el-menu-item>
        </el-submenu>
        <el-submenu index="3">
src/components/makepager/BomDialog.vue
@@ -26,7 +26,7 @@
        </el-table-column>
        <el-table-column prop="createdAt" label="设为默认">
          <template slot-scope="scope">
          <el-switch @change="switchChange(scope,scope.row.isDefault)"  v-model="scope.row.isDefault"></el-switch>
          <el-switch @change="switchChange(scope,scope.row[editRow.isDefault])"  v-model="scope.row[editRow.isDefault]"></el-switch>
          </template>
    
        </el-table-column>
@@ -68,7 +68,9 @@
    editRow: {
      type: Object,
      default: () => {
        return {};
        return {
          isDefault:'isDefault'
        };
      },
    },
    workList:{
@@ -79,45 +81,10 @@
    return {
      editDialogVisible: false,
      isTableShow:true,
      form: {},
      BomTableData: [1],
      work: 1,
      flag: "add",
      Tabs: "msg",
      tableData: [
        {
          date: "PEBU",
          name: "PE布",
          number: "21",
          unit: "吨",
        },
      ],
      rules: {
        id: [{ required: true, message: "请输入物料编码", trigger: "blur" }],
        name: [
          { required: true, message: "请输入物料名称", trigger: "blur" },
        ],
        specs: [{ required: true, message: "请输入物料规格", trigger: "blur" }],
        type: [{ required: true, message: "请输入物料型号", trigger: "blur" }],
        amount: [
          {
            required: true,
            message: "请输入数量",
            trigger: "blur",
          },
        ],
        unit: [
          {
            required: true,
            message: "请输入单位",
            trigger: "blur",
          },
        ],
        model: [
          { required: true, message: "请选择物料类型", trigger: "change" },
        ],
      },
    };
  },
  watch: {
@@ -136,7 +103,7 @@
  },
  methods: {
    handleAdd() {
      this.BomTableData.push({name:'',isDefault:false});
      this.BomTableData.push({name:'',[this.editRow.isDefault]:false,sort:this.BomTableData.length});
    },
    handleDelete(scope) {
      this.BomTableData.splice(scope.$index,1)
@@ -148,7 +115,7 @@
    switchChange(scope,val){
      let arr=[]
      for(let i in this.BomTableData){
        if(this.BomTableData[i].isDefault){
        if(this.BomTableData[i][this.editRow.isDefault]){
          arr.push(i)
        }
      }
@@ -157,13 +124,13 @@
          message: '只能设一个为默认',
          type: "warning",
        });
        scope.row.isDefault=!val
        scope.row[this.editRow.isDefault]=!val
      }
    },
    handleConfirmSave() {
      let arr=[]
      for(let i in this.BomTableData){
        if(this.BomTableData[i].isDefault){
        if(this.BomTableData[i][this.editRow.isDefault]){
          arr.push(i)
        }
      }
src/components/makepager/TableCommonView.vue
@@ -311,9 +311,15 @@
  }
}
::v-deep {
  .el-table__footer-wrapper tbody td.el-table__cell {
    background-color: #fff;
    text-align: right;
  .el-table__footer-wrapper  {
    tbody td.el-table__cell{
      background-color: #fff;
    }
    // .cell{
    //     &:nth-last-child(3){
    //       text-align:right;
    //     }
    //   }
  }
}
</style>
src/views/purchaseManage/purchase/DetailSupplier.vue
@@ -153,6 +153,7 @@
<script>
import { deletePurchase } from "@/api/purchaseManage/purchase";
import { getDataByType } from "@/api/data";
export default {
  name: "DetailSupplier",
  props: {
@@ -184,10 +185,11 @@
      tableList: {},
      showSummary:{
        show: true,
        sumProp: ["number", "total"],
        mergeNumber: 4,
        sumProp: ["amount", "total"],
        mergeNumber: 5,
        totalName:'小计'
      },
      purchaseStatusList:getDataByType('purchaseStatus'),
    };
  },
  created() {
@@ -197,6 +199,17 @@
  mounted() {},
  computed: {},
  methods: {
    getpurchaseStatus(val) {
      if (val) {
        for (let i in this.purchaseStatusList) {
          if (this.purchaseStatusList[i].id == val) {
            return this.purchaseStatusList[i].name;
          }
        }
      } else {
        return "--";
      }
    },
    // email 通知下单
    emailClick() {},
    // 删除
@@ -267,7 +280,7 @@
        },
        {
          leftStr: "采购单状态",
          leftValue: item.contact_name,
          leftValue: this.getpurchaseStatus(item.status),
          rightStr: "采购负责人",
          rightValue: item.contact_position,
        },
@@ -285,7 +298,7 @@
        },
        {
          leftStr: "到货仓库",
          leftValue: item.sales_resources,
          leftValue: item.warehouse,
          rightStr: "",
          rightValue: "",
        },
@@ -314,8 +327,8 @@
        tableInfomation: item.productList?item.productList:[],
        selectIndex: true,
        tableColumn: [
          { label: "产品名称", prop: "name", min: 190, isCommonClick: true },
          { label: "产品编码", prop: "number", min: 130, isCommonClick: true },
          { label: "产品名称", prop: "name", min: 160,  },
          { label: "产品编码", prop: "number", min: 130, },
          { label: "计量单位", prop: "unit", min: 130 },
          { label: "规格型号", prop: "specifications", min: 130 },
          { label: "数量", prop: "amount", min: 130 },
src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -37,9 +37,9 @@
                  >
                    <el-option
                      v-for="ele in plcBrandList"
                      :key="ele.id"
                      :key="ele.name"
                      :label="ele.name"
                      :value="ele.name"
                      :value="ele.ID"
                    ></el-option>
                  </el-select>
                  <i
@@ -85,9 +85,9 @@
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="单据来源" prop="number">
                <el-form-item label="单据来源" prop="orderSource">
                  <el-input
                    v-model="editConfig.infomation.number"
                    v-model="editConfig.infomation.orderSource"
                    disabled
                    placeholder="请填写"
                  ></el-input>
@@ -177,7 +177,7 @@
              <div class="table-bottom-l">
                <el-form-item label="整单折扣" prop="member_id">
                  <el-select
                    v-model="editConfig.infomation.fieldName"
                    v-model="editConfig.infomation.wholeDiscountType"
                    placeholder="请选择"
                    filterable
                  >
@@ -189,7 +189,7 @@
              <div class="table-bottom-r">
                <el-form-item label="" prop="member_id">
                  <el-input
                    v-model="editConfig.infomation.number"
                    v-model="editConfig.infomation.wholeDiscount"
                    size="mini"
                    placeholder="请填写"
                  ></el-input>
@@ -200,7 +200,7 @@
              <div class="table-bottom-l">
                <el-form-item label="调整" prop="member_id">
                  <el-select
                    v-model="editConfig.infomation.fieldName"
                    v-model="editConfig.infomation.priceAdjustmentType"
                    placeholder="请选择"
                    filterable
                  >
@@ -212,7 +212,7 @@
              <div class="table-bottom-r">
                <el-form-item label="" prop="member_id">
                  <el-input
                    v-model="editConfig.infomation.number"
                    v-model="editConfig.infomation.priceAdjustment"
                    size="mini"
                    placeholder="请填写"
                  ></el-input>
@@ -221,7 +221,7 @@
            </div>
            <div class="table-bottom-item">
              <div class="table-bottom-l">合计</div>
              <div class="table-bottom-r">26000.00</div>
              <div class="table-bottom-r">{{ editConfig.infomation.realTotalPrice }}</div>
            </div>
          </div>
        </div>
@@ -246,6 +246,7 @@
      ref="editDialog"
      @sucessSet="handleGetBomKindDictList"
      @handleConfirmSave="handleConfirmSave"
      :editRow="editRow"
      :workList="plcBrandList"
      title="采购类型"
    ></BomDialog>
@@ -259,11 +260,10 @@
import {
  addPurchase,
  updatePurchase,
  savePurchaseType,
  getPurchaseType,
} from "@/api/purchaseManage/purchase";
// import {
//   postGetUnitDictList,
//   postGetSaveSUnitDict,
// } from "@/api/purchaseManage/purchase";
import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog";
export default {
  name: "QuotationDialog",
@@ -284,6 +284,7 @@
    return {
      editConfig: this.editCommonConfig,
      rules: {
        purchaseTypeId:[{ required: true, message: "请选择", trigger: "change" }],
        supplierName: [{ required: true, message: "请选择", trigger: "change" }],
        phone: [
          {
@@ -292,6 +293,22 @@
            trigger: "change",
          },
          { validator: this.validatorPhone, trigger: "change" },
        ],
        wholeDiscount: [
          {
            required: false,
            message: "请填写",
            trigger: "change",
          },
          { validator: this.validatorNum, trigger: "change" },
        ],
        priceAdjustment: [
          {
            required: false,
            message: "请填写",
            trigger: "change",
          },
          { validator: this.validatorNumThree, trigger: "change" },
        ],
      },
      productTableList: {},
@@ -321,6 +338,9 @@
      isNoProduct: true,
      clientList: [],
      plcBrandList:[],
      editRow:{
        isDefault:'pin'
      }
    };
  },
  created() {
@@ -332,46 +352,80 @@
    'editCommonConfig.visible':{
      immediate:true,
      handler:function(){
        this.setTableForm();
      }
    }
  },
  methods: {
    validatorNum(rule, value, callback) {
      if (value) {
        if (value == undefined || value == null) {
          callback(new Error("请输入有效数字"));
        } else {
          var reg = /^\+?[0-9]\d*$/;
          if (!reg.test(value)) {
            callback(new Error("请填写不小于0的数字"));
          } else {
            callback();
          }
        }
      } else {
        callback();
      }
    },
    validatorNumThree(rule, value, callback){
      if(value){
        if(value==undefined||value==null){
          callback(new Error("请输入有效数字"));
        }else{
          let reg2=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
          if(!reg2.test(value)){
            callback(new Error('请填写2位小数的数字'))
          }else{
            callback()
          }
        }
      }else{
        callback()
      }
    },
    // PLC配置设置
    handleShow() {
      // this.handleGetBomKindDictList();
      this.handleGetBomKindDictList();
      this.$refs.editDialog.editDialogVisible = true;
    },
    //  PLC配置
    handleGetBomKindDictList(val) {
      console.log(val,'val')
      // postGetUnitDictList().then((res) => {
      //   this.plcBrandList = res.data;
      //   if (val) {
      //     for (let i in this.plcBrandList) {
      //       if (this.plcBrandList[i].isDefault) {
      //         this.form.unit = this.form.unit
      //           ? this.form.unit
      //           : this.plcBrandList[i].name;
      //         this.$set(this.form, "unit", this.form.unit);
      //         break;
      //       }
      //     }
      //   }
      // });
      getPurchaseType().then((res) => {
        this.plcBrandList = res.data;
        if (val) {
          for (let i in this.plcBrandList) {
            if (this.plcBrandList[i][this.editRow.isDefault]) {
              this.editConfig.infomation.purchaseTypeId = this.editConfig.infomation.purchaseTypeId
                ? this.editConfig.infomation.purchaseTypeId
                : this.plcBrandList[i].ID;
              this.$set(this.editConfig.infomation, "purchaseTypeId", this.editConfig.infomation.purchaseTypeId);
              break;
            }
          }
        }
      });
    },
    handleConfirmSave(data) {
      console.log(data,'data')
      // postGetSaveSUnitDict({ data: data }).then((res) => {
      //   if (res.code == 200) {
      //     this.$message({
      //       message: "操作成功!",
      //       type: "success",
      //     });
      //     this.$refs.editDialog.editDialogVisible = false;
      //     this.handleGetBomKindDictList();
      //   }
      // });
      savePurchaseType(data).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: "操作成功!",
            type: "success",
          });
          this.$refs.editDialog.editDialogVisible = false;
          this.handleGetBomKindDictList(true);
        }
      });
    },
    validatorPhone(rule, value, callback) {
      if (value) {
@@ -437,7 +491,6 @@
      });
    },
    saveParams() {
      debugger
      let data =JSON.parse(JSON.stringify(this.editConfig.infomation));
      let params = {
        productList:this.tableData,
@@ -445,11 +498,17 @@
          supplierId:this.supplierId||0,
          signingDate:data.signingDate||'',
          remark:data.remark,
          purchaseTypeId:this.purchaseTypeId||0,
          orderSource:data.orderSource||'',
          purchaseTypeId:data.purchaseTypeId||0,
          phone:data.phone||'',
          name:data.name||'',
          deliveryDate:data.deliveryDate||'',
          contact:data.contact
          contact:data.contact,
          wholeDiscountType:data.wholeDiscountType,
          wholeDiscount:Number(data.wholeDiscount),
          priceAdjustmentType:data.priceAdjustmentType,
          priceAdjustment:Number(data.priceAdjustment),
          realTotalPrice:data.realTotalPrice||'',
        }
      };
      if(data.ID){
@@ -530,6 +589,7 @@
          {
            label: "产品名称",
            prop: "name",
            min: 170,
            productName: true,
            isRequird: true,
          },
@@ -547,6 +607,7 @@
          { label: "描述", prop: "remark", input: true },
        ],
      };
      this.handleGetBomKindDictList(true);
    },
    // 产品列表输入
    inputContent(val, prop, row) {
src/views/purchaseManage/purchase/index.vue
@@ -21,6 +21,11 @@
          @selCommonClick="selCommonClick"
        >
          <template slot="tableButton">
            <el-table-column label="状态" width="120">
              <template slot-scope="scope">
               {{ getpurchaseStatus(scope.row.status) }}
              </template>
            </el-table-column>
            <el-table-column label="操作" width="120" fixed="right">
              <template slot-scope="scope">
                <el-button type="text"  size="small" @click="editClick(scope.row)"  style="margin-right: 5px"
@@ -69,7 +74,7 @@
        visible: false,
        infomation: {}
      },
      search_map: {},
      search:'',
      editRow:{},
      editConfig: {
        visible: false,
@@ -84,6 +89,17 @@
    this.getData()
  },
  methods: {
    getpurchaseStatus(val) {
      if (val) {
        for (let i in this.purchaseStatusList) {
          if (this.purchaseStatusList[i].id == val) {
            return this.purchaseStatusList[i].name;
          }
        }
      } else {
        return "--";
      }
    },
    setTable() {
      this.tableList = {
        tableInfomation: [],
@@ -91,20 +107,19 @@
        tableColumn: [
          { label: "采购单号", prop: "number", min: 150, isCommonClick: true },
          { label: "采购单名称", prop: "name", min: 130, isCommonClick: true},
          { label: "单据类型", prop: "contact_name", min: 130 },
          { label: "单据类型", prop: "orderType", min: 130 },
          { label: "供应商名称", prop: "contact", min: 130 },
          { label: "采购数量", prop: "sales_resources", min: 130 },
          { label: "收货仓库", prop: "province", min: 130 },
          { label: "经办人", prop: "city", min: 130 },
          { label: "制单人", prop: "member_name", min: 130 },
          { label: "状态", prop: "member_name", min: 130 },
          { label: "采购数量", prop: "quantity", min: 130 },
          { label: "收货仓库", prop: "warehouse", min: 130 },
          { label: "经办人", prop: "handledBy", min: 130 },
          { label: "制单人", prop: "creator", min: 130 },
        ]
      }
    },
    // 请求数据
    async getData() {
      await getPurchaseList({
        keyword: this.search_map,
        keyword: this.search,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
@@ -122,13 +137,11 @@
    // 搜索
    searchClick(val, content) {
      console.log(val, content)
      this.search_map = {
        [val.value]: content
      }
      this.search =  content
      this.getData()
    },
    resetClick() {
      this.search_map = {}
      this.search = ''
      this.getData()
    },
    // 新建
@@ -139,14 +152,16 @@
      this.editConfig.title = "创建"
      this.editConfig.infomation = {
        productList:[],
        purchaseTypeId:'',
        supplierId:'',
        supplierName:'',
        orderSource:'手动创建',
        name:'',
        contact:'',
        phone:'',
          signingDate:'',
          remark:'',
          purchaseTypeId:'',
          phone:'',
          name:'',
          deliveryDate:'',
          contact:''
          remark:'',
       }
    },
    
@@ -158,7 +173,8 @@
          this.editConfig.title = "编辑"
          this.editConfig.infomation = { 
            productList:res.data.productList,
            ...res.data.purchase
            supplierName:res.data.purchase.supplier.name,
            ...res.data.purchase,
           }
        }else{
          this.$message.error(res.msg?res.msg+',':''+'获取信息失败!')
src/views/purchaseManage/quality/index.vue
@@ -16,9 +16,13 @@
          ref="tableListRef"
          :table-list="tableList"
          @selCommonClick="selCommonClick"
          @getSelectArray="getSelectArray"
        >
          <template slot="tableButton">
            <el-table-column label="状态" width="120">
              <template slot-scope="scope">
               {{ getQualityStatus(scope.row.member_name) }}
              </template>
            </el-table-column>
            <el-table-column label="操作" width="120" fixed="right">
              <template slot-scope="scope">
                <el-button  @click="qualityClick(scope.row)" type="text" size="small">去质检</el-button>
@@ -41,9 +45,11 @@
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getSalesLeadsList, getDeleteSalesLeads } from "@/api/client/salesLead"
import {
  getPurchaseList,getPurchaseInfo,submitPurchase,
} from "@/api/purchaseManage/purchase";
import DetailSupplier from "@/views/purchaseManage/quality/DetailSupplier"
import { getDataByType } from "@/api/data";
export default {
  name: "SupplierManage",
  props: {},
@@ -58,7 +64,8 @@
        visible: false,
        infomation: {}
      },
      search_map: {}
      search: {},
      qualityStatusList:getDataByType('qualityStatus'),
    }
  },
  created() {
@@ -66,6 +73,17 @@
    this.getData()
  },
  methods: {
    getQualityStatus(val) {
      if (val) {
        for (let i in this.qualityStatusList) {
          if (this.qualityStatusList[i].id == val) {
            return this.qualityStatusList[i].name;
          }
        }
      } else {
        return "--";
      }
    },
    setTable() {
      this.tableList = {
        tableInfomation: [],
@@ -78,30 +96,22 @@
          { label: "到货仓库", prop: "sales_resources", min: 130 },
          { label: "质检数量", prop: "province", min: 130 },
          { label: "检验员", prop: "city", min: 130 },
          { label: "状态", prop: "member_name", min: 110 },
          // { label: "状态", prop: "member_name", min: 110 },
          { label: "质检时间", prop: "member_name", min: 150 },
        ]
      }
    },
    // 请求数据
    async getData() {
      await getSalesLeadsList({
        search_map: this.search_map,
      await getPurchaseList({
        keyword: this.search,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          const list = res.data.list.map((item) => {
            return {
              ...item,
              province: item.Province.name,
              city: item.City.name,
              sales_resources: item.sales_sources.name,
              member_name: item.member.username
            }
          })
          const list = res.data.data.list
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.data.count
          this.pagerOptions.totalCount = res.data.data.total
        })
        .catch((err) => {
          console.log(err)
@@ -110,13 +120,11 @@
    // 搜索
    searchClick(val, content) {
      console.log(val, content)
      this.search_map = {
        [val.value]: content
      }
      this.search = content
      this.getData()
    },
    resetClick() {
      this.search_map = {}
      this.search = ''
      this.getData()
    },
   
@@ -129,7 +137,7 @@
        })
          .then(() => {
            console.log("dddd")
            getDeleteSalesLeads({ ids: this.selValueList }).then((response) => {
            submitPurchase({ ids: this.selValueList }).then((response) => {
              if (response.code === 200) {
                this.$message.success("确认发货成功")
                this.getData()
@@ -140,18 +148,21 @@
          })
          .catch(() => {})
    },
    getSelectArray(val) {
      this.selValueList = []
      const list = val.map((item) => {
        return item.id
      })
      this.selValueList = list
    },
    // 详情
    selCommonClick(row) {
      console.log(row)
      this.commonDetail.visible = true
      this.commonDetail.infomation = { ...row }
      getPurchaseInfo({id:row.ID}).then((res) => {
        if (res.code == 200) {
          this.commonDetail.visible = true
          this.commonDetail.infomation = {
            productList:res.data.productList,
            ...res.data.purchase
           }
        }else{
          this.$message.error(res.msg?res.msg+',':''+'获取信息失败!')
        }
      })
    }
  }
}
src/views/purchaseManage/returned/index.vue
@@ -17,9 +17,13 @@
          ref="tableListRef"
          :table-list="tableList"
          @selCommonClick="selCommonClick"
          @getSelectArray="getSelectArray"
        >
          <template slot="tableButton">
            <el-table-column label="状态" width="120">
              <template slot-scope="scope">
               {{ getReturnedStatus(scope.row.member_name) }}
              </template>
            </el-table-column>
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-button  @click="confirmClick(scope.row)" type="text" size="small">确认发货</el-button>
@@ -42,9 +46,11 @@
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getSalesLeadsList, getDeleteSalesLeads } from "@/api/client/salesLead"
import {
  getPurchaseList,getPurchaseInfo,submitPurchase,
} from "@/api/purchaseManage/purchase";
import DetailSupplier from "@/views/purchaseManage/returned/DetailSupplier"
import { getDataByType } from "@/api/data";
export default {
  name: "SupplierManage",
  props: {},
@@ -59,7 +65,8 @@
        visible: false,
        infomation: {}
      },
      search_map: {}
      search: '',
      returnedStatusList:getDataByType('returnedStatus'),
    }
  },
  created() {
@@ -67,6 +74,17 @@
    this.getData()
  },
  methods: {
    getReturnedStatus(val) {
      if (val) {
        for (let i in this.returnedStatusList) {
          if (this.returnedStatusList[i].id == val) {
            return this.returnedStatusList[i].name;
          }
        }
      } else {
        return "--";
      }
    },
    setTable() {
      this.tableList = {
        tableInfomation: [],
@@ -81,29 +99,21 @@
          { label: "经办人", prop: "city", min: 130 },
          { label: "制单人", prop: "member_name", min: 130 },
          { label: "退货日期", prop: "member_name", min: 150 },
          { label: "状态", prop: "member_name", min: 110 }
          // { label: "状态", prop: "member_name", min: 110 }
        ]
      }
    },
    // 请求数据
    async getData() {
      await getSalesLeadsList({
        search_map: this.search_map,
      await getPurchaseList({
        keyword: this.search,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          const list = res.data.list.map((item) => {
            return {
              ...item,
              province: item.Province.name,
              city: item.City.name,
              sales_resources: item.sales_sources.name,
              member_name: item.member.username
            }
          })
          const list = res.data.data.list
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.data.count
          this.pagerOptions.totalCount = res.data.total
        })
        .catch((err) => {
          console.log(err)
@@ -112,13 +122,12 @@
    // 搜索
    searchClick(val, content) {
      console.log(val, content)
      this.search_map = {
        [val.value]: content
      }
      this.search =  content
      this.getData()
    },
    resetClick() {
      this.search_map = {}
      this.search = ''
      this.getData()
    },
   
@@ -131,7 +140,7 @@
        })
          .then(() => {
            console.log("dddd")
            getDeleteSalesLeads({ ids: this.selValueList }).then((response) => {
            submitPurchase({ ids: this.selValueList }).then((response) => {
              if (response.code === 200) {
                this.$message.success("确认发货成功")
                this.getData()
@@ -142,18 +151,21 @@
          })
          .catch(() => {})
    },
    getSelectArray(val) {
      this.selValueList = []
      const list = val.map((item) => {
        return item.id
      })
      this.selValueList = list
    },
    // 详情
    selCommonClick(row) {
      console.log(row)
      this.commonDetail.visible = true
      this.commonDetail.infomation = { ...row }
      getPurchaseInfo({id:row.ID}).then((res) => {
        if (res.code == 200) {
          this.commonDetail.visible = true
          this.commonDetail.infomation = {
            productList:res.data.productList,
            ...res.data.purchase
           }
        }else{
          this.$message.error(res.msg?res.msg+',':''+'获取信息失败!')
        }
      })
    }
  }
}