src/views/supplierManage/supplier/index.vue
@@ -22,8 +22,9 @@
              ref="tableSupplier"
              :table-list="tableList"
              @selCommonClick="selCommonClick"
              @tableRowClick="tableRowClick"
              @selTableCol="selTableCol"
              @tableRowClick="tableRowClick"
              :selectClassRow="selectRow"
            >
              <template slot="tableButton">
                <el-table-column label="操作" width="100">
@@ -57,12 +58,12 @@
            :amount-view="false"
            :show-screen="false"
            :show-action-btn="false"
            :placeholder="'请输入产品名称'"
            :placeholder="'请输入产品名称/产品规格/产品编码'"
            @searchClick="onProductFilterSearch"
          >
            <template slot="leftButton">
              <div class="sub-title"><span class="sub-title-decorator"></span>可提供的产品</div>
              <el-button type="primary" size="mini">创建采购单</el-button>
              <el-button type="primary" size="mini" @click="creatPurchase">创建采购单</el-button>
            </template>
            <template slot="rightButton">
              <el-button type="primary" size="mini" @click="addNewProductClick">添加新产品</el-button>
@@ -109,23 +110,27 @@
    <!-- 相关供应商 -->
    <RaleteSupplierList v-if="raleteSupplierConfig.visible" :common-config="raleteSupplierConfig" />
    <!-- 添加新产品 -->
    <AddNewProduct v-if="newProductConfig.visible" :add-common-config="newProductConfig" />
    <AddNewProduct v-if="newProductConfig.visible" :disabledList="productTableList.tableInfomation" :add-common-config="newProductConfig" />
    <!-- 新建/编辑 -->
    <AddPurchase v-if="editPurchaseConfig.visible" :edit-common-config="editPurchaseConfig" />
  </div>
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getSupplierList, changeSupplierStatus } from "@/api/supplierManage/supplier"
import { getPurchaseList } from "@/api/purchaseManage/purchase"
import DetailSupplier from "@/views/supplierManage/supplier/DetailSupplier"
import AddSupplier from "@/views/supplierManage/supplier/AddSupplier"
import RaleteSupplierList from "@/views/supplierManage/supplier/RaleteSupplierList"
import AddNewProduct from "@/views/supplierManage/supplier/AddNewProduct"
import { getProductList, deleteProduct } from "@/api/productManage/product"
import { getProductListTwo, deleteProduct } from "@/api/productManage/product"
import AddPurchase from "@/views/purchaseManage/purchase/components/AddPurchase"
export default {
  name: "SupplierManage",
  props: {},
  components: { DetailSupplier, AddSupplier, RaleteSupplierList, AddNewProduct },
  components: { DetailSupplier, AddSupplier, RaleteSupplierList, AddNewProduct, AddPurchase },
  mixins: [pageMixin],
  computed: {},
  data() {
@@ -138,7 +143,8 @@
      searchProductOptions: [], // 产品查询
      commonDetail: {
        visible: false,
        infomation: {}
        infomation: {},
        productListInfo: []
      },
      editConfig: {
        visible: false,
@@ -180,7 +186,16 @@
        { label: "采购价格", prop: "purchasePrice", min: 130 },
        { label: "供货时长(天)", prop: "deliveryTime", min: 130 },
        { label: "物流时长(天)", prop: "shippingDuration", min: 130 }
      ]
      ],
      editPurchaseConfig: {
        // 创建采购
        visible: false,
        title: "创建",
        infomation: {
          supplierName: ""
        }
      },
      selectRow: {}
    }
  },
  created() {
@@ -269,6 +284,7 @@
          const list = res.data.list.map((item) => {
            return {
              ...item,
              id: item.id,
              status_name: item.status === 0 ? "未启用" : "启用"
            }
          })
@@ -276,13 +292,14 @@
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.data.total
          if (list && list.length > 0) {
            this.supplierId = this.tableList.tableInfomation[0].ID
            this.supplierId = this.tableList.tableInfomation[0].id
            this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
          } else {
            this.supplierId = 0
          }
          this.$nextTick(() => {
            this.$refs.tableSupplier.$refs.table.setCurrentRow(this.tableList.tableInfomation[0])
          })
          // this.$nextTick(() => {
          //   this.$refs.tableSupplier.$refs.table.setCurrentRow(this.tableList.tableInfomation[0])
          // })
          // 重新获取供应商列表后应该重置产品列表页码
          this.productPagerOptions.currPage = 1
@@ -300,20 +317,19 @@
    // 产品列表
    async getProductList(val, content) {
      console.log(val, content)
      await getProductList({
      await getProductListTwo({
        [val]: content,
        supplierId: this.supplierId,
        page: this.productPagerOptions.currPage,
        pageSize: this.productPagerOptions.pageSize
      }).then((res) => {
        console.log(res.data)
        const list = res.data.data.list.map((item) => {
        let list = res.data.list.map((item) => {
          return {
            ...item
          }
        })
        this.productTableList.tableInfomation = list || []
        this.productPagerOptions.totalCount = res.data.data.total
        this.productPagerOptions.totalCount = res.data.total
      })
    },
    // 搜索供应商
@@ -325,19 +341,22 @@
    // 搜索产品
    onProductFilterSearch(searchText) {
      this.productPagerOptions.currPage = 1
      this.getProductList("name", searchText)
      this.getProductList("keyword", searchText)
    },
    // 新建供应商
    addBtnClick() {
      this.editConfig.visible = true
      this.editConfig.title = "新建"
      this.editConfig.infomation = { fileId: 0 }
      this.editConfig.infomation = {
        fileId: 0,
        responsiblePersonName: document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
      }
    },
    // 启用供应商
    async enableClick(row, value) {
      let status = value === "启用" ? 1 : 0
      await changeSupplierStatus({
        id: row.ID,
        id: Number(row.id),
        status: status
      }).then((res) => {
        if (res.code === 200) {
@@ -366,7 +385,6 @@
    },
    // 修改产品
    editClick(row) {
      console.log(row)
      this.newProductConfig.visible = true
      this.newProductConfig.title = "修改"
      this.newProductConfig.infomation = { ...row }
@@ -379,7 +397,7 @@
        type: "warning"
      })
        .then(() => {
          deleteProduct({ id: row.ID }).then((response) => {
          deleteProduct({ id: row.id }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getProductList()
@@ -399,14 +417,16 @@
      this.selValueList = list
    },
    tableRowClick(row) {
      console.log(row)
      this.productPagerOptions.currPage = 1
      this.supplierId = row.ID
      this.selectRow = row
      this.supplierId = row.id
      this.getProductList()
    },
    // 详情
    selCommonClick(row) {
      console.log(row)
    async selCommonClick(row) {
      await getPurchaseList({ pageSize: 10, page: 1, supplierId: Number(row.id) }).then((res) => {
        this.commonDetail.productListInfo = res.data.list
      })
      this.commonDetail.visible = true
      this.commonDetail.infomation = { ...row }
    },
@@ -419,6 +439,16 @@
    currentProductHandler(val) {
      this.productPagerOptions.currPage = val
      this.getProductList()
    },
    // 创建采购单
    creatPurchase() {
      this.editPurchaseConfig.visible = true
      this.editPurchaseConfig.title = "新建"
      this.editPurchaseConfig.infomation = {
        supplierId: this.selectRow.id,
        purchaseTypeId: "2",
        supplierName: this.selectRow.name
      }
    }
  }
}