haoxuan
2023-10-17 90660a13752f2e5b2c778bb1d7c9e6915346dbde
src/views/other/payment/saleInvoice/addSaleInvoice.vue
@@ -13,7 +13,7 @@
        :model="editConfig.infomation"
        :rules="rules"
        label-position="right"
        label-width="308px"
        label-width="168px"
        size="mini"
        style="height: 60vh; overflow-x: hidden"
      >
@@ -24,15 +24,31 @@
          <div class="basic-info-view">
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题" prop="subject">
                  <el-input v-model="editConfig.infomation.subject"></el-input>
                <el-form-item label="发票编号" prop="number">
                  <WordInput
                    v-if="codenumer && (explain != '' || isIdDisabled)&&method == 0"
                    :codenumer="codenumer"
                    :sum="sum"
                    :disabled="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>自动生成</span>
                </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 label="主题" prop="subject">
                  <el-input v-model="editConfig.infomation.subject" style="width: 100%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="客户名称" prop="client_name">
                  <div class="custom-name">
@@ -45,12 +61,17 @@
                      "
                      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>
@@ -63,6 +84,7 @@
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                      style="width: 100%"
                    >
                      <el-option v-for="item in invoiceTypeOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
@@ -79,6 +101,7 @@
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                      style="width: 100%"
                    >
                      <el-option
                        v-for="item in invoiceStatusOptions"
@@ -98,7 +121,7 @@
                    v-model="editConfig.infomation.principalId"
                    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>
@@ -117,12 +140,20 @@
                      "
                      value-key="number"
                      @select="handleSelectClient('serviceContract', $event)"
                      style="width: 100%"
                    ></el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick('serviceContract')">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
                    <div class="common-select-btn" @click="clearupClient('serviceContract')">
                      <i class="el-icon-edit-outline" title="清除"></i>
                    <div
                      v-if="
                        editConfig.infomation.serviceContract_Number &&
                        editConfig.infomation.serviceContract_Number.length > 0
                      "
                      class="common-select-btn"
                      @click="clearupClient('serviceContract')"
                    >
                      <i class="el-icon-remove-outline" title="清除"></i>
                    </div>
                  </div>
                </el-form-item>
@@ -139,19 +170,24 @@
                      "
                      value-key="number"
                      @select="handleSelectClient('contract', $event)"
                      style="width: 100%"
                    ></el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick('contract')">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
                    <div class="common-select-btn" @click="clearupClient('contract')">
                      <i class="el-icon-edit-outline" title="清除"></i>
                    <div
                      v-if="editConfig.infomation.number && editConfig.infomation.number.length > 0"
                      class="common-select-btn"
                      @click="clearupClient('contract')"
                    >
                      <i class="el-icon-remove-outline" title="清除"></i>
                    </div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="纳税识别号" prop="taxpayerIdNumber">
                  <el-input v-model="editConfig.infomation.taxpayerIdNumber"></el-input>
                  <el-input v-model="editConfig.infomation.taxpayerIdNumber" style="width: 100%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
@@ -168,6 +204,7 @@
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                      style="width: 100%"
                    >
                      <el-option
                        v-for="item in courierCompanyOptions"
@@ -183,7 +220,7 @@
              </el-col>
              <el-col :span="12">
                <el-form-item label="物流单号" prop="courierNumber">
                  <el-input v-model="editConfig.infomation.courierNumber"></el-input>
                  <el-input v-model="editConfig.infomation.courierNumber" style="width: 100%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
@@ -193,13 +230,14 @@
                    value-format="yyyy-MM-dd"
                    type="date"
                    placeholder="选择日期"
                    style="width: 100%"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="发票号码" prop="invoiceNumber">
                  <el-input v-model="editConfig.infomation.invoiceNumber"></el-input>
                  <el-input v-model="editConfig.infomation.invoiceNumber" style="width: 100%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
@@ -340,8 +378,10 @@
import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog"
import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog"
import { addInvoice, getInvoiceTypeList, getInvoiceStatusList, getCourierCompanyList } from "@/api/common/payment"
import codeMixin from "@/views/client/followupRecords/mixin/codeMixin";
export default {
  name: "AddSaleInvoiceDialog",
  mixins: [codeMixin],
  props: {
    editCommonConfig: {
      type: Object,
@@ -369,7 +409,7 @@
  },
  data() {
    return {
      dialogWidth: "80%",
      dialogWidth: "50%",
      editConfig: this.editCommonConfig,
      rules: {
        subject: [{ required: true, message: "请输入主题", trigger: "blur" }],
@@ -388,7 +428,7 @@
        show: true,
        total: true,
        sumProp: ["Amount", "Unit", "total"],
        mergeNumber: 3
        mergeNumber: 2
      },
      editSelectClientConfig: {
        editVisible: false,
@@ -413,8 +453,7 @@
      clientId: this.editCommonConfig.infomation.client_id,
      SalesDetailsId: this.editCommonConfig.infomation.SalesDetailsId,
      serviceContractId: this.editCommonConfig.infomation.id,
      tableData: [],
      productId: 1
      tableData: []
    }
  },
  created() {
@@ -423,8 +462,27 @@
    this.$store.dispatch("geSalesDetails")
    this.setTableForm()
    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) => {
        if (res.code === 200) {
@@ -465,28 +523,41 @@
    // 保存
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        this.validateFormNumber()
        if (valid) {
          console.log(this.editConfig.infomation)
          const params = this.saveParams()
          console.log(params)
          if (this.editConfig.title === "新建") {
            addInvoice(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("添加成功")
                this.$parent.getData()
              }
            })
          for (let i = 0; i < this.tableData.length; i++) {
            if (this.tableData[i].name.length === 0) {
              this.isNoProduct = true
              break
            } else {
              this.isNoProduct = false
            }
          }
          if (this.isNoProduct) {
            this.$message.error("产品名称不能为空")
          } else {
            // getUpdateServiceContract(params).then((res) => {
            //   console.log(res)
            //   this.editConfig.visible = false
            //   if (res.code === 200) {
            //     this.$message.success("编辑成功")
            //     this.$parent.getData()
            //   }
            // })
            const params = this.saveParams()
            console.log(params)
            if (this.editConfig.title === "新建") {
              addInvoice(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("添加成功")
                  this.$parent.getData()
                }
              })
            } else {
              // getUpdateServiceContract(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")
@@ -559,8 +630,8 @@
      }
    },
    selClient(row, value) {
      if (value === "contact") {
        this.editConfig.infomation.contact_name = row.name
      if (value === "client") {
        this.editConfig.infomation.client_name = row.name
        this.contactId = row.id
      } else if (value === "serviceContract") {
        this.editConfig.infomation.serviceContract_Number = row.number
@@ -588,86 +659,84 @@
    // 设置允许上传文件格式
    setFormatClick() {},
    setTableForm() {
      if (this.editConfig.title === "新建") {
      if (this.editConfig.title === "新建" || this.editConfig.infomation.products.length === 0) {
        this.tableData = [
          {
            id: 1,
            Amount: 0,
            IsSale: true,
            MaterialMode: "",
            MinInventory: 0,
            Name: "",
            Number: "",
            PurchaseType: "",
            SalePrice: 0,
            Unit: ""
            productId: this.productId,
            id: 0,
            amount: 0,
            desc: "",
            name: "",
            number: "",
            price: 0,
            total: 0
          }
        ]
      } else {
        this.tableData = this.editConfig.infomation.products
        this.tableData.map((item, index) => {
          item.productId = index + 1
        })
      }
      this.productTableList = {
        tableData: this.tableData,
        tableColumn: [
          { label: "#", prop: "id", width: 40 },
          { label: "产品名称", prop: "Name", input: true, isRequird: true },
          { label: "产品编号", prop: "Number" },
          { label: "数量", prop: "Amount", input: true, isRequird: true },
          { label: "销售单价", prop: "Unit", input: true },
          { label: "价税合计", prop: "total", input: true },
          { label: "描述", prop: "other8" }
          { label: "#", prop: "productId", width: 40 },
          { label: "产品名称", prop: "name", productName: true, isRequird: true },
          { label: "产品编号", prop: "number" },
          { label: "数量", prop: "amount", inputNumber: true, isRequird: true },
          { label: "销售单价", prop: "price", inputFloat: true },
          { label: "价税合计", prop: "total", inputFloat: true }
        ]
      }
    },
    // 产品列表输入
    inputContent(val, prop, row) {
      console.log("aaaaaaaa")
      console.log(val, prop)
      this.productId = row.id
      this.productId = row.productId
      this.tableData.map((item) => {
        if (item.id === row.id) {
        if (item.productId === row.productId) {
          item[prop] = val
        }
      })
      console.log(this.tableData)
    },
    // 产品新增
    addProductClick() {
      this.productId++
      this.tableData.push({
        id: this.productId,
        Amount: 0,
        IsSale: true,
        MaterialMode: "",
        MinInventory: 0,
        Name: "",
        Number: "",
        PurchaseType: "",
        SalePrice: 0,
        Unit: ""
        productId: this.productId,
        id: 0,
        amount: 0,
        desc: "",
        name: "",
        number: "",
        price: 0,
        total: 0
      })
      this.showSummary.show = true
    },
    //  产品清空
    emptyProductClick() {
      this.productId = 1
      this.tableData = [
        {
          id: 1,
          Amount: 0,
          IsSale: true,
          MaterialMode: "",
          MinInventory: 0,
          Name: "",
          Number: "",
          PurchaseType: "",
          SalePrice: 0,
          Unit: ""
          productId: this.productId,
          id: 0,
          amount: 0,
          desc: "",
          name: "",
          number: "",
          price: 0,
          total: 0
        }
      ]
      this.productTableList.tableData = this.tableData
    },
    // 产品重算
    recalculateProductClick() {}
    recalculateProductClick() {},
    clearupProduct(data) {
      this.tableData = data
      this.productTableList.tableData = this.tableData
    }
  }
}
</script>