yangfeng
2023-08-18 96fdf32bd5612b6c16dcbcc8352a9f54adcc8e7e
src/views/sales/contractManage/AddContractManageDialog.vue
@@ -25,14 +25,18 @@
                  <div class="custom-name">
                    <el-autocomplete
                      v-model="editConfig.infomation.client_name"
                      :fetch-suggestions="querySearchAsync"
                      :fetch-suggestions="
                        (queryString, callback) => {
                          querySearchAsync(queryString, callback, 'client')
                        }
                      "
                      value-key="name"
                      @select="handleSelectClient"
                      @select="handleSelectClient('client', $event)"
                    ></el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick">
                    <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">
                    <div class="common-select-btn" @click="clearupClient('client')">
                      <i class="el-icon-edit-outline" title="清除"></i>
                    </div>
                  </div>
@@ -44,9 +48,9 @@
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="负责人" prop="member_id">
                <el-form-item label="负责人" prop="memberId">
                  <el-select
                    v-model="editConfig.infomation.member_id"
                    v-model="editConfig.infomation.memberId"
                    placeholder="请选择"
                    size="mini"
                    style="width: 63%"
@@ -68,23 +72,36 @@
                      <el-option v-for="item in statusOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="销售报价单" prop="quotation_id">
                <el-form-item label="销售报价单" prop="quotationId">
                  <div class="custom-name">
                    <el-input v-model="editConfig.infomation.quotation_id"></el-input>
                    <div class="common-select-btn"><i class="el-icon-circle-plus-outline" title="选择"></i></div>
                    <div class="common-select-btn"><i class="el-icon-edit" title="编辑"></i></div>
                    <el-autocomplete
                      v-model="editConfig.infomation.quotation_number"
                      :fetch-suggestions="
                        (queryString, callback) => {
                          querySearchAsync(queryString, callback, 'quotation')
                        }
                      "
                      value-key="number"
                      @select="handleSelectClient('quotation', $event)"
                    ></el-autocomplete>
                    <div 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>
                  </div>
                </el-form-item>
              </el-col>
            </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">
@@ -109,13 +126,13 @@
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          </div> -->
          <!-- 展开收起 -->
          <div v-if="editConfig.title === '新建'" class="unflod-collapse" @click="unflodCollapseClick">
          <!-- <div v-if="editConfig.title === '新建'" class="unflod-collapse" @click="unflodCollapseClick">
            <div>{{ unflodCollapseStr }}</div>
            <div v-if="isUnflod"><i class="el-icon-arrow-up"></i></div>
            <div v-else><i class="el-icon-arrow-down"></i></div>
          </div>
          </div> -->
          <!-- 选择审批流程 -->
          <!-- <div class="basic-info-title">选择审批流程</div>
          <div class="basic-info-view">
@@ -168,6 +185,12 @@
        :edit-common-config="editSelectClientConfig"
        @selClient="selClient"
      />
      <!-- 报价单 -->
      <SelectCommonDialog
        v-if="editSelCommonConfig.editVisible"
        :edit-common-config="editSelCommonConfig"
        @selClient="selClient"
      />
    </el-dialog>
  </div>
</template>
@@ -176,6 +199,7 @@
import { getAllData } from "@/api/client/client"
import { getAddContract, getUpdateContract } from "@/api/sales/contractManage"
import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog"
import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog"
export default {
  name: "AddContractManageDialog",
  props: {
@@ -190,10 +214,13 @@
      }
    }
  },
  components: { SelectClientDialog },
  components: { SelectClientDialog, SelectCommonDialog },
  computed: {
    clientList() {
      return this.$store.state.getClientName.clientList
    },
    quotationList() {
      return this.$store.state.getClientName.quotationList
    }
  },
  data() {
@@ -213,11 +240,19 @@
        editVisible: false,
        title: "",
        infomation: {}
      }
      },
      editSelCommonConfig: {
        editVisible: false,
        title: "",
        infomation: {}
      },
      clientId: this.editCommonConfig.infomation.clientId,
      quotationId: this.editCommonConfig.infomation.quotationId
    }
  },
  created() {
    this.$store.dispatch("geClient")
    this.$store.dispatch("geQuotation")
    this.getCommonData()
  },
  methods: {
@@ -239,37 +274,23 @@
          const params = this.saveParams()
          console.log(params)
          if (this.editConfig.title === "新建") {
            getAddContract(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)
              })
            getAddContract(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("添加成功")
                this.$parent.getData()
              }
            })
          } else {
            getUpdateContract(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)
              })
            getUpdateContract(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("编辑成功")
                this.$parent.getData()
              }
            })
          }
        } else {
          console.log("error submit")
@@ -281,11 +302,11 @@
      let data = this.editConfig.infomation
      let params = {
        id: this.editConfig.title === "新建" ? 0 : data.id,
        client_id: parseInt(data.client_id) || 0,
        client_id: this.clientId || 0,
        file: "",
        member_id: data.member_id || 0,
        number: data.number || "",
        quotation_id: data.quotation_id || 0,
        quotation_id: this.quotationId || 0,
        status_id: data.status_id || 0
      }
      return params
@@ -294,31 +315,61 @@
      this.editConfig.visible = false
    },
    // 选择客户相关方法
    querySearchAsync(queryString, cb) {
      var restaurants = this.clientList
      var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
    querySearchAsync(queryString, cb, value) {
      var restaurants = []
      if (value === "client") {
        restaurants = this.clientList
      } else if (value === "quotation") {
        restaurants = this.quotationList
      }
      var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
      cb(results)
    },
    createStateFilter(queryString) {
    createStateFilter(queryString, value) {
      return (state) => {
        return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        if (value === "contract" || value === "quotation") {
          return state.number.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        } else {
          return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        }
      }
    },
    handleSelectClient(item) {
      this.editConfig.infomation.client_id = item.id
    handleSelectClient(value, item) {
      console.log(value)
      if (value === "client") {
        this.clientId = item.id
      } else if (value === "quotation") {
        this.quotationId = item.id
      }
    },
    selClientClick() {
      this.editSelectClientConfig.editVisible = true
    selClientClick(value) {
      if (value === "client") {
        this.editSelectClientConfig.editVisible = true
      } else if (value === "quotation") {
        this.editSelCommonConfig.title = "报价单"
        this.editSelCommonConfig.editVisible = true
        this.editSelCommonConfig.tableInfomation = [...this.quotationList]
      }
    },
    selClient(row) {
      console.log(row)
      this.editConfig.infomation.client_name = row.name
      this.editConfig.infomation.client_id = row.id
    selClient(row, value) {
      console.log(value)
      if (value === "contact") {
        this.editConfig.infomation.contact_name = row.name
        this.contactId = row.id
      } else if (value === "quotation") {
        this.editConfig.infomation.quotation_number = row.number
        this.quotationId = row.id
      }
    },
    // 清除已选择用户
    clearupClient() {
      this.editConfig.infomation.client_name = ""
      this.editConfig.infomation.client_id = 0
    clearupClient(value) {
      if (value === "client") {
        this.editConfig.infomation.client_name = ""
        this.clientId = 0
      } else if (value === "quotation") {
        this.editConfig.infomation.quotation_number = ""
        this.quotationId = 0
      }
    },
    // 添加附件
    addAnnexClick() {},