yangfeng
2023-07-19 23d80c1b64f23ede237ab8e89ebc2ee2aaf43f26
src/views/service/serviceFeeManage/AddServiceFeeManageDialog.vue
@@ -284,6 +284,8 @@
<script>
import CommonSelectView from "@/components/makepager/CommonSelectView"
import { getAllData } from "@/api/client/client"
import { getAddSubOrder, getUpdateSubOrder } from "@/api/sales/subOrder"
export default {
  name: "AddServiceFeeManageDialog",
  props: {
@@ -293,34 +295,7 @@
        return {
          visible: false,
          title: "新建",
          infomation: {
            customName: "",
            serviceCharger: "",
            customNumber: "",
            customerSize: "",
            customStatus: "",
            importantLevel: "",
            customType: "",
            customSource: "",
            serviceAgent: "",
            latestServiceDate: "",
            contactName: "",
            duties: "",
            phoneNumber: "",
            contactsEmail: "",
            operateRange: "",
            position: "",
            map: "",
            country: "1",
            province: "1",
            city: "1",
            region: "1",
            address: "",
            industry: "",
            companyNature: "",
            companyWeb: "",
            notes: ""
          }
          infomation: {}
        }
      }
    }
@@ -379,8 +354,87 @@
      isUnflod: true
    }
  },
  created() {},
  created() {
    this.getCommonData()
  },
  methods: {
    getCommonData() {
      getAllData()
        .then((res) => {
          this.memberOptions = res.data.member
        })
        .catch((err) => {
          console.log(err)
        })
    },
    // 保存
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.editConfig.infomation)
          const params = this.saveParams()
          console.log(params)
          if (this.editConfig.title === "新建") {
            getAddSubOrder(params)
              .then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message({
                    message: "添加成功",
                    type: "success"
                  })
                  this.$parent.getData()
                }
              })
              .catch((err) => {
                console.log(err)
              })
          } else {
            getUpdateSubOrder(params)
              .then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message({
                    message: "编辑成功",
                    type: "success"
                  })
                  this.$parent.getData()
                }
              })
              .catch((err) => {
                console.log(err)
              })
          }
        } else {
          console.log("error submit")
          return false
        }
      })
    },
    saveParams() {
      let data = this.editConfig.infomation
      let params = {
        id: this.editConfig.title === "新建" ? 0 : data.id,
        clientId: data.clientId || 0,
        masterOrderId: data.masterOrderId || 0,
        memberId: data.memberId || 0,
        number: data.number || "",
        product: [
          {
            amount: 0,
            desc: "",
            id: 0,
            name: "",
            number: "",
            price: 0,
            total: 0
          }
        ]
      }
      return params
    },
    handleClose() {
      this.editConfig.visible = false
    },