yangfeng
2023-11-23 4d6d23e986f1cc9fed61f3161c46b4f2be069fb7
src/views/sales/salesDetails/index.vue
@@ -102,6 +102,36 @@
        </div>
      </div>
    </div>
    <!-- 确认提交-选择项目 -->
    <el-dialog
      title="请选择项目"
      :visible.sync="projectListShow"
      width="40%"
      :before-close="handleClose">
      <el-form
        label-width="100px"
        class="demo-ruleForm"
        ref="form"
        :rules="rules"
        :model="projects"
      >
        <el-form-item  label="选择项目" prop="projectId">
          <el-select
            v-model="projects.projectId"
            placeholder="请选择"
            size="mini"
            style="width: 100%"
          >
            <el-option v-for="item in projectList" :key="item.projectId" :label="item.projectName" :value="item.projectId">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="projectListShow = false">取 消</el-button>
        <el-button type="primary" @click="affirmCommitBtn">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 新建/编辑 -->
    <AddSalesDetailsDialog
      v-if="editConfig.visible"
@@ -124,7 +154,11 @@
  getDelSalesDetails,
  getProductInventoryInfo,
  getProductOrderInfo,
  updateStatus
  updateStatus,
  createOperation,
  getProjectList,
  getUpdateSalesDetails,
  sendSalesDetailsToApsProject
} from "@/api/sales/salesDetails"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import DetailSpecification from "@/views/sales/salesDetails/DetailSpecification"
@@ -159,35 +193,35 @@
  data() {
    // 产品信息
    const productColumn = [
      { label: "产品编号", prop: "Id", default: true },
      { label: "产品名称", prop: "Name" },
      { label: "数量", prop: "Amount" },
      { label: "单位", prop: "Unit" },
      { label: "发货单", prop: "shipOrder" },
      { label: "产品编号", prop: "id", default: true },
      { label: "产品名称", prop: "name" },
      { label: "数量", prop: "amount" },
      { label: "单位", prop: "unit" },
      { label: "发货单", prop: "invoice" },
      { label: "承运商", prop: "carrier" },
      { label: "运单号", prop: "waybillNumber" },
      { label: "销售单价", prop: "SalePrice", price: true },
      { label: "价税合计", prop: "Valorem", price: true }
      { label: "销售单价", prop: "salePrice", price: true },
      { label: "价税合计", prop: "valorem", price: true }
    ]
    // 库存信息
    const inventoryColumn = [
      { label: "产品编号", prop: "Id", default: true },
      { label: "产品名称", prop: "Name" },
      { label: "订单数量", prop: "OrderAmount" },
      { label: "仓库", prop: "Warehouse" },
      { label: "在库数量", prop: "Amount" },
      { label: "可用库存", prop: "AvailableNumber" },
      { label: "单位", prop: "Unit" }
      { label: "产品编号", prop: "id", default: true },
      { label: "产品名称", prop: "name" },
      { label: "订单数量", prop: "orderAmount" },
      { label: "仓库", prop: "warehouse" },
      { label: "在库数量", prop: "amount" },
      { label: "可用库存", prop: "availableNumber" },
      { label: "单位", prop: "unit" }
    ]
    // 制造信息
    const makeColumn = [
      { label: "生产订单", prop: "OrderId", default: true },
      { label: "产品名称", prop: "ProductName" },
      { label: "订单状态", prop: "OrderStatus" },
      { label: "工单编号", prop: "WorkOrderId" },
      { label: "工单状态", prop: "WorkOrderStatus" },
      { label: "计划开始时间", prop: "StartTime" },
      { label: "计划结束时间", prop: "EndTime" }
      { label: "生产订单", prop: "orderId", default: true },
      { label: "产品名称", prop: "productName" },
      { label: "订单状态", prop: "orderStatus" },
      { label: "工单编号", prop: "workOrderId" },
      { label: "工单状态", prop: "workOrderStatus" },
      { label: "计划开始时间", prop: "startTime" },
      { label: "计划结束时间", prop: "endTime" }
    ]
    return {
      tableList: {},
@@ -201,7 +235,7 @@
        show: false,
        sumProp: [
          "receiveTotalAmount",
          "total",
          "amountTotal",
          "amountReceivable",
          "invoicedAmount",
          "uninvoicedAmount",
@@ -239,7 +273,7 @@
        { label: "签约日期", prop: "signTime" },
        { label: "交付日期", prop: "deliveryDate" },
        { label: "订单来源", prop: "source" },
        { label: "合计", prop: "total", price: true },
        { label: "合计", prop: "amountTotal", price: true },
        { label: "状态", prop: "status", isCallMethod: true, getCallMethod: this.getStatus }
      ],
      showCol: ["订单编号", "销售负责人", "签约日期", "交付日期", "订单来源", "合计", "状态"],
@@ -256,7 +290,16 @@
      showInventoryCol: ["产品编号", "产品名称", "订单数量", "仓库", "在库数量", "可用库存", "单位"],
      makeColumn: makeColumn,
      showMakeCol: ["生产订单", "产品名称", "订单状态", "工单编号", "工单状态", "计划开始时间", "计划结束时间"],
      selectRow: {}
      selectRow: {},
      projectList:[],
      projectListShow:false,
      projects:{
        projectId:'',
      },
      thatRow:{},
      rules: {
        projectId: [{ required: true, message: "请选择项目", trigger: "change" }],
      },
    }
  },
  created() {
@@ -269,6 +312,7 @@
      this.keywordType = this.addConfig.keywordType
    }
    this.getData()
    this.getProjectList()
  },
  methods: {
    setTable() {
@@ -374,7 +418,7 @@
              if (res.data.count > 0) {
                this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
                let row = this.tableList.tableInfomation[0]
                this.getProductInventoryInfo(row.number)
                this.getProductInventoryInfo(row)
              }
            } else {
              this.tableList.tableInfomation = []
@@ -391,11 +435,16 @@
        })
    },
    // 获取产品/库存信息
    async getProductInventoryInfo(number) {
      await getProductInventoryInfo(number).then((res) => {
        console.log(res)
        this.productTableList.tableInfomation = res.data
      })
    async getProductInventoryInfo(row) {
      console.log(row.status, "状态", row)
      if (row.status === 1) {
        this.productTableList.tableInfomation = row.products
      } else {
        await getProductInventoryInfo(row.number).then((res) => {
          console.log(res)
          this.productTableList.tableInfomation = res.data
        })
      }
    },
    // 获取制造信息
    async getProductOrderInfo(number) {
@@ -440,8 +489,28 @@
    },
    // 确认提交
    async submitClick(row) {
      console.log(row, "确认提交")
      this.updateStatus(row.id, 2)
      this.thatRow=row
      if(row.projectId==""){
        this.$message.error("请先填写项目信息")
        this.projectListShow=true
      }else{
        let params = {
          ...row,
          status: 2
        }
        await createOperation(params).then((res) => {
          if (res.code == 200) {
            this.$message.success("确认提交成功")
            this.getData()
            this.thatRow.status=2
            sendSalesDetailsToApsProject(this.thatRow).then((res)=>{
              if(res.code===200){
                this.$message.success("成功推送至aps系统")
              }
            })
          }
        })
      }
    },
    // 关闭
    closeClick(row) {
@@ -456,7 +525,7 @@
      }).then((res) => {
        console.log(res)
        if (res.code == 200) {
          this.$message.success("修改成功")
          this.$message.success("关闭成功")
          this.getData()
        }
      })
@@ -527,7 +596,7 @@
        this.tableBottomColumn = this.productColumn
        this.showBottomCol = this.showProductCol
        this.setBottomList()
        this.getProductInventoryInfo(this.selectRow.number)
        this.getProductInventoryInfo(this.selectRow)
      } else if (this.TabsIndex == 1) {
        this.isClickProduct = false
        this.isClickInventory = true
@@ -536,7 +605,7 @@
        this.tableBottomColumn = this.inventoryColumn
        this.showBottomCol = this.showInventoryCol
        this.setBottomList()
        this.getProductInventoryInfo(this.selectRow.number)
        this.getProductInventoryInfo(this.selectRow)
      } else if (this.TabsIndex == 2) {
        this.isClickProduct = false
        this.isClickInventory = false
@@ -557,12 +626,89 @@
      console.log(row, column, event)
      this.selectRow = row
      if (this.TabsIndex == 0) {
        this.getProductInventoryInfo(this.selectRow.number)
        this.getProductInventoryInfo(this.selectRow)
      } else if (this.TabsIndex == 1) {
        this.getProductInventoryInfo(this.selectRow.number)
        this.getProductInventoryInfo(this.selectRow)
      } else if (this.TabsIndex == 2) {
        this.getProductOrderInfo(this.selectRow.number)
      }
    },
    // 获取项目列表
    async getProjectList(){
      await getProjectList({
        page: 1,
        pageSize: 100,
      }).then((res) => {
        console.log(res.data,"项目列表信息")
        this.projectList=res.data
      })
    },
    handleClose(done) {
      done()
    },
    saveParams() {
      let params={
        address: this.thatRow.address || "",
        addressee: this.thatRow.addressee || "",
        clientId: this.thatRow.clientId || 0,
        conditions: this.thatRow.conditions || "",
        deliveryDate: this.thatRow.deliveryDate || "",
        memberId: this.thatRow.memberId || 0,
        number: this.thatRow.number || "",
        phone: this.thatRow.phone || "",
        products: this.thatRow.products,
        remark: this.thatRow.remark || "",
        saleChanceId: this.thatRow.saleChanceId || 0,
        saleType: this.thatRow.saleType || 0,
        signTime: this.thatRow.signTime || "",
        wechatOrderStatus: this.thatRow.wechatOrderStatus || 0,
        logisticCompany: this.thatRow.logisticCompany || "",
        logisticCost: this.thatRow.logisticCost || 0,
        logisticNumber: this.thatRow.logisticNumber || "",
        quotationId: this.thatRow.quotationId,
        deliverType: this.thatRow.deliverType || 0,
        status:  this.thatRow.deliverType,
        projectId:this.projects.projectId||0
      }
      return params
    },
    // 确认提交
    affirmCommitBtn(){
      let params=this.saveParams()
      this.$refs['form'].validate((valid) => {
        if(valid){
          console.log()
          this.projectListShow=false
          getUpdateSalesDetails({
            id:this.thatRow.id,
            salesDetails:params
          }).then((res) => {
            console.log(res)
            this.editConfig.visible = false
            if (res.code === 200) {
              let params2 = {
                ...this.thatRow,
                status: 2
              }
              createOperation(params2).then((res) => {
                if (res.code == 200) {
                  this.$message.success("提交成功")
                  this.getData()
                  this.thatRow.status=2
                  sendSalesDetailsToApsProject(this.thatRow).then((res)=>{
                    if(res.code===200){
                      this.$message.success("成功推送至aps系统")
                    }
                  })
                }
              })
            }
          }).catch((err)=>{
            this.$message.error(`编辑失败:${err}`)
          })
        }
      })
    }
  }
}
@@ -664,4 +810,8 @@
.bgcWhite {
  background: #fff !important;
}
.el-form-item{
  width: 80%;
  margin: 20px auto;
}
</style>