haoxuan
2023-10-17 90660a13752f2e5b2c778bb1d7c9e6915346dbde
src/views/sales/contractManage/AddContractManageDialog.vue
@@ -11,7 +11,7 @@
        :model="editConfig.infomation"
        :rules="rules"
        label-position="right"
        label-width="308px"
        label-width="168px"
        size="mini"
      >
        <!-- 信息 -->
@@ -20,6 +20,30 @@
          <div class="basic-info-title">基本信息</div>
          <div class="basic-info-view">
            <el-row>
              <el-col :span="12">
                <el-form-item label="单据编号" prop="number">
                  <!-- <el-input v-model="editConfig.infomation.number" style="width: 100%"></el-input> -->
                  <WordInput
                    v-if="codenumer && (explain != '' || isIdDisabled) && method == 0"
                    :codenumer="codenumer"
                    :sum="sum"
                    :disabled="editConfig.title !== '新建' || isIdDisabled"
                    :inputValue="inputValue"
                    @codeList="codeList"
                  />
                  <span v-else-if="method == 0" style="color: #f56c6c"
                    >请优先配置编码规范 <el-button type="text" @click="numberClick"> 配置规范 </el-button></span
                  >
                  <span v-else>{{ editConfig.title === "新建" ? "自动生成" : editConfig.infomation.number }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="合同名称" prop="contractName">
                  <div class="custom-name">
                    <el-input v-model="editConfig.infomation.contractName"></el-input>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="客户名称" prop="client_name">
                  <div class="custom-name">
@@ -32,19 +56,19 @@
                      "
                      value-key="name"
                      @select="handleSelectClient('client', $event)"
                      style="width: 100%"
                    ></el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick('client')">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
                    <div class="common-select-btn" @click="clearupClient('client')">
                      <i class="el-icon-edit-outline" title="清除"></i>
                    <div
                      v-if="editConfig.infomation.client_name && editConfig.infomation.client_name.length > 0"
                      class="common-select-btn"
                      @click="clearupClient('client')"
                    >
                      <i class="el-icon-remove-outline" title="清除"></i>
                    </div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="单据编号" prop="number">
                  <el-input v-model="editConfig.infomation.number"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
@@ -53,7 +77,7 @@
                    v-model="editConfig.infomation.memberId"
                    placeholder="请选择"
                    size="mini"
                    style="width: 63%"
                    style="width: 100%"
                  >
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    </el-option>
@@ -61,13 +85,14 @@
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="合同状态" prop="status_id">
                <el-form-item label="合同状态" prop="statusId">
                  <div class="common-select">
                    <el-select
                      v-model="editConfig.infomation.status_id"
                      v-model="editConfig.infomation.statusId"
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                      style="width: 100%"
                    >
                      <el-option v-for="item in statusOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
@@ -77,7 +102,7 @@
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="销售报价单" prop="quotationId">
                <el-form-item label="销售报价单" prop="quotation_number">
                  <div class="custom-name">
                    <el-autocomplete
                      v-model="editConfig.infomation.quotation_number"
@@ -88,12 +113,23 @@
                      "
                      value-key="number"
                      @select="handleSelectClient('quotation', $event)"
                      style="width: 100%"
                      placeholder="请先选择客户名称"
                      :disabled="isAddQuatation"
                    ></el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick('quotation')">
                    <div v-if="!isAddQuatation" class="common-select-btn" @click="selClientClick('quotation')">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
                    <div class="common-select-btn" @click="clearupClient('quotation')">
                      <i class="el-icon-edit-outline" title="清除"></i>
                    <div
                      v-if="
                        editConfig.infomation.quotation_number &&
                        editConfig.infomation.quotation_number.length > 0 &&
                        !isAddQuatation
                      "
                      class="common-select-btn"
                      @click="clearupClient('quotation')"
                    >
                      <i class="el-icon-remove-outline" title="清除"></i>
                    </div>
                  </div>
                </el-form-item>
@@ -101,7 +137,7 @@
            </el-row>
          </div>
          <!-- 附件信息 -->
          <!-- <div v-if="isUnflod" class="basic-info-title">附件信息</div>
          <div v-if="isUnflod" class="basic-info-title">附件信息</div>
          <div class="basic-info-view">
            <el-row>
              <el-col :span="12">
@@ -126,7 +162,7 @@
                </el-form-item>
              </el-col>
            </el-row>
          </div> -->
          </div>
          <!-- 展开收起 -->
          <!-- <div v-if="editConfig.title === '新建'" class="unflod-collapse" @click="unflodCollapseClick">
            <div>{{ unflodCollapseStr }}</div>
@@ -200,8 +236,11 @@
import { getAddContract, getUpdateContract } from "@/api/sales/contractManage"
import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog"
import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog"
import codeMixin from "@/views/client/followupRecords/mixin/codeMixin"
import { getQuotationList } from "@/api/sales/quotation"
export default {
  name: "AddContractManageDialog",
  mixins: [codeMixin],
  props: {
    editCommonConfig: {
      type: Object,
@@ -218,18 +257,20 @@
  computed: {
    clientList() {
      return this.$store.state.getClientName.clientList
    },
    quotationList() {
      return this.$store.state.getClientName.quotationList
    }
    // quotationList() {
    //   return this.$store.state.getClientName.quotationList
    // }
  },
  data() {
    return {
      dialogWidth: "80%",
      dialogWidth: "50%",
      editConfig: this.editCommonConfig,
      rules: {
        number: [{ required: true, message: "请输入", trigger: "blur" }],
        member_id: [{ required: true, message: "请选择", trigger: "change" }]
        number: [{ required: true, validator: this.checkCode, trigger: "blur" }],
        client_name: [{ required: true, message: "请选择客户名称", trigger: "change" }],
        member_id: [{ required: true, message: "请选择", trigger: "change" }],
        contractName: [{ required: true, message: "请输入合同名称", trigger: "blur" }]
      },
      memberOptions: [],
      statusOptions: [], // 合同状态
@@ -247,15 +288,39 @@
        infomation: {}
      },
      clientId: this.editCommonConfig.infomation.clientId,
      quotationId: this.editCommonConfig.infomation.quotationId
      quotationId: this.editCommonConfig.infomation.quotationId,
      isAddQuatation: true,
      quotationList: []
    }
  },
  created() {
    this.$store.dispatch("geClient")
    this.$store.dispatch("geQuotation")
    // this.$store.dispatch("geQuotation")
    if (this.editConfig.title !== "新建") {
      this.isAddQuatation = false
    }
    this.getCommonData()
    this.formInfo()
  },
  watch: {
    "editCommonConfig.visible"(val) {
      if (val) {
        this.formInfo()
      }
    },
    "editCommonConfig.infomation.codeStandID"() {
      this.formInfo()
    }
  },
  methods: {
    formInfo() {
      this.objCode.type = "合同编码"
      this.objCode.codeStandID = ""
      if (this.editConfig.infomation.codeStandID) {
        this.objCode.codeStandID = this.editConfig.infomation.codeStandID
      }
      this.getRCodeStandardList()
    },
    getCommonData() {
      getAllData()
        .then((res) => {
@@ -269,6 +334,7 @@
    // 保存
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        this.validateFormNumber()
        if (valid) {
          console.log(this.editConfig.infomation)
          const params = this.saveParams()
@@ -300,19 +366,38 @@
    },
    saveParams() {
      let data = this.editConfig.infomation
      console.log(data)
      let params = {
        id: this.editConfig.title === "新建" ? 0 : data.id,
        contractName: data.contractName || "",
        client_id: this.clientId || 0,
        file: "",
        member_id: data.member_id || 0,
        member_id: data.memberId || 0,
        number: data.number || "",
        quotation_id: this.quotationId || 0,
        status_id: data.status_id || 0
        status_id: data.statusId || 0,
        codeStandID: data.ID,
        codeRule: this.codeRule
      }
      return params
    },
    handleClose() {
      this.editConfig.visible = false
    },
    // 获取报价单
    getQuotation(id) {
      getQuotationList({
        page: 0,
        pageSize: 0,
        search_map: {
          client_id: id
        }
      }).then((res) => {
        if (res.code == 200) {
          console.log(res)
          this.quotationList = res.data.list
        }
      })
    },
    // 选择客户相关方法
    querySearchAsync(queryString, cb, value) {
@@ -335,27 +420,36 @@
      }
    },
    handleSelectClient(value, item) {
      console.log(value)
      console.log(item)
      if (value === "client") {
        this.editConfig.infomation.client_name = item.name
        this.clientId = item.id
        this.isAddQuatation = false
        this.getQuotation(item.id)
      } else if (value === "quotation") {
        this.editConfig.infomation.quotation_number = item.number
        this.quotationId = item.id
      }
    },
    selClientClick(value) {
      console.log("aaaa")
      if (value === "client") {
        this.editSelectClientConfig.editVisible = true
      } else if (value === "quotation") {
        this.editSelCommonConfig.title = "报价单"
        this.editSelCommonConfig.editVisible = true
        this.editSelCommonConfig.clientId = this.clientId
        this.editSelCommonConfig.tableInfomation = [...this.quotationList]
      }
    },
    selClient(row, value) {
      console.log("bbbb")
      console.log(value)
      if (value === "contact") {
        this.editConfig.infomation.contact_name = row.name
        this.contactId = row.id
      if (value === "client") {
        this.editConfig.infomation.client_name = row.name
        this.clientId = row.id
        this.isAddQuatation = false
        this.getQuotation(row.id)
      } else if (value === "quotation") {
        this.editConfig.infomation.quotation_number = row.number
        this.quotationId = row.id
@@ -363,9 +457,13 @@
    },
    // 清除已选择用户
    clearupClient(value) {
      console.log(value)
      if (value === "client") {
        this.editConfig.infomation.client_name = ""
        this.clientId = 0
        this.isAddQuatation = true
        this.editConfig.infomation.quotation_number = ""
        this.quotationId = 0
      } else if (value === "quotation") {
        this.editConfig.infomation.quotation_number = ""
        this.quotationId = 0
@@ -384,6 +482,14 @@
        this.unflodCollapseStr = "收起"
        this.isUnflod = true
      }
    },
    // 订单编码单独校验
    checkCode(rule, value, callback) {
      if (this.editConfig.infomation.number && this.editConfig.infomation.number.length > 0) {
        callback()
      } else {
        callback(new Error("请输入单据编号"))
      }
    }
  }
}