gaoluyang
3 天以前 6e3bb34e45df6a2f19f1592fb1b06c574dd026cd
src/views/procurementManagement/procurementLedger/index.vue
@@ -94,7 +94,7 @@
        <el-table-column
          label="项目名称"
          prop="projectName"
          width="100"
          width="420"
          show-overflow-tooltip
        />
        <el-table-column
@@ -134,6 +134,7 @@
              type="primary"
              size="small"
              @click="openForm('edit', scope.row)"
                     :disabled="scope.row.receiptPaymentAmount>0 || scope.row.recorderName !== userStore.nickName"
              >编辑</el-button
            >
          </template>
@@ -288,7 +289,7 @@
          <el-table-column label="规格型号" prop="specificationModel" />
          <el-table-column label="单位" prop="unit" width="70" />
          <el-table-column label="数量" prop="quantity" width="70" />
          <el-table-column label="税率(%)" prop="taxRate" width="70" />
          <el-table-column label="税率(%)" prop="taxRate" width="80" />
          <el-table-column
            label="含税单价(元)"
            prop="taxInclusiveUnitPrice"
@@ -429,18 +430,20 @@
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="数量:" prop="quantity">
              <el-input-number
              :step="0.1"
                clearable
                style="width: 100%"
                v-model="productForm.quantity"
                placeholder="请输入"
                @change="mathNum"
              />
            </el-form-item>
          </el-col>
               <el-col :span="12">
                  <el-form-item label="税率(%):" prop="taxRate">
                     <el-select
                        v-model="productForm.taxRate"
                        placeholder="请选择"
                        clearable
                        @change="mathNum"
                     >
                        <el-option label="1" value="1" />
                        <el-option label="6" value="6" />
                        <el-option label="13" value="13" />
                     </el-select>
                  </el-form-item>
               </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
@@ -455,20 +458,18 @@
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="税率(%):" prop="taxRate">
              <el-select
                v-model="productForm.taxRate"
                placeholder="请选择"
                clearable
                @change="mathNum"
              >
                <el-option label="1" value="1" />
                <el-option label="6" value="6" />
                <el-option label="13" value="13" />
              </el-select>
            </el-form-item>
          </el-col>
               <el-col :span="12">
                  <el-form-item label="数量:" prop="quantity">
                     <el-input-number
                        :step="0.1"
                        clearable
                        style="width: 100%"
                        v-model="productForm.quantity"
                        placeholder="请输入"
                        @change="mathNum"
                     />
                  </el-form-item>
               </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
@@ -479,7 +480,7 @@
                :step="0.1"
                clearable
                style="width: 100%"
                disabled
                @change="reverseMathNum('taxInclusiveTotalPrice')"
              />
            </el-form-item>
          </el-col>
@@ -488,7 +489,10 @@
              label="不含税总价(元):"
              prop="taxExclusiveTotalPrice"
            >
              <el-input v-model="productForm.taxExclusiveTotalPrice" disabled />
              <el-input
                v-model="productForm.taxExclusiveTotalPrice"
                @change="reverseMathNum('taxExclusiveTotalPrice')"
              />
            </el-form-item>
          </el-col>
        </el-row>
@@ -788,6 +792,10 @@
// 移除文件
function handleRemove(file) {
  console.log("handleRemove", file.id);
  if (file.size > 1024 * 1024 * 10) {
    // 仅前端清理,不调用删除接口和提示
    return;
  }
  if (operationType.value === "edit") {
    let ids = [];
    ids.push(file.id);
@@ -981,6 +989,12 @@
const handleDelete = () => {
  let ids = [];
  if (selectedRows.value.length > 0) {
      // 检查是否有他人维护的数据
      const unauthorizedData = selectedRows.value.filter(item => item.recorderName !== userStore.nickName);
      if (unauthorizedData.length > 0) {
         proxy.$modal.msgWarning("不可删除他人维护的数据");
         return;
      }
    ids = selectedRows.value.map((item) => item.id);
  } else {
    proxy.$modal.msgWarning("请选择数据");
@@ -1010,7 +1024,10 @@
  return `${year}-${month}-${day}`;
}
const mathNum = () => {
  console.log("productForm.value", productForm.value);
   if (!productForm.value.taxRate) {
      proxy.$modal.msgWarning("请先选择税率");
      return;
   }
  if (!productForm.value.taxInclusiveUnitPrice) {
    return;
  }
@@ -1032,6 +1049,43 @@
      );
  }
};
const reverseMathNum = (field) => {
   if (!productForm.value.taxRate) {
      proxy.$modal.msgWarning("请先选择税率");
      return;
   }
  const taxRate = Number(productForm.value.taxRate);
  if (!taxRate) return;
  if (field === 'taxInclusiveTotalPrice') {
    // 已知含税总价和数量,反算含税单价
    if (productForm.value.quantity) {
      productForm.value.taxInclusiveUnitPrice =
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2);
    }
    // 已知含税总价和含税单价,反算数量
    else if (productForm.value.taxInclusiveUnitPrice) {
      productForm.value.quantity =
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
    }
    // 反算不含税总价
    productForm.value.taxExclusiveTotalPrice =
      (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).toFixed(2);
  } else if (field === 'taxExclusiveTotalPrice') {
    // 反算含税总价
    productForm.value.taxInclusiveTotalPrice =
      (Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)).toFixed(2);
    // 已知数量,反算含税单价
    if (productForm.value.quantity) {
      productForm.value.taxInclusiveUnitPrice =
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2);
    }
    // 已知含税单价,反算数量
    else if (productForm.value.taxInclusiveUnitPrice) {
      productForm.value.quantity =
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
    }
  }
};
// 销售合同选择改变方法
const salesLedgerChange = async (row) => {
  console.log("row", row);