ly 1 жил өмнө
parent
commit
9d940b9886

+ 45 - 16
src/views/business/financial/contract/form.vue

@@ -449,33 +449,62 @@
       const amount = form.value.arriveAmount;
       if (amount > form.value.contractAmount) {
         proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
-        return;
+        return false;
       }
-      form.value.details.forEach(item => {
-        if (item.amount < item.arriveAmount) {
-          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
-          return;
+      for (let i = 0; i < form.value.details.length; i++) {
+        let item = form.value.details[i];
+        let countAmount = 0;
+        for (let j = 0; j < res.data.length; j++) {
+            let match = res.data[j];
+            if (item.taskTypeId == match.taskTypeId) {
+                countAmount += match.arriveAmount;
+            }
         }
-      });
+        if (item.amount < countAmount) {
+            proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+            return false;
+        }
+    }
+
     } else {
-      const countAmount= res.data.map((item) => item.arriveAmount).reduce((total, number) => {
+      const countAmount = res.data.map((item) => item.arriveAmount).reduce((total, number) => {
         return total + number;
       });
-      console.log("res.data",res.data);
       const amount = countAmount + form.value.arriveAmount;
       if (amount > form.value.contractAmount) {
         proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
-        return;
+        return false;
       }
-      form.value.details.forEach(item => {
-        if (item.amount < match.add(item.arriveAmount, item.arrived)) {
-          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
-          return;
+
+      // form.value.details.forEach(item => {
+      //   let countAmount = 0;
+      //   res.data.forEach(match => {
+      //     if (item.taskTypeId == match.taskTypeId) {
+      //       countAmount += match.arriveAmount;
+      //     }
+      //   })
+      //   if (item.amount < match.add(item.arriveAmount,countAmount)) {
+      //     proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+      //     console.log(2323);
+      //     return false;
+      //   }
+      // });
+      for (let i = 0; i < form.value.details.length; i++) {
+        let item = form.value.details[i];
+        let countAmount = 0;
+        for (let j = 0; j < res.data.length; j++) {
+            let match = res.data[j];
+            if (item.taskTypeId == match.taskTypeId) {
+                countAmount += match.arriveAmount;
+            }
+        }
+        if (item.amount < match.add(item.arriveAmount,countAmount)) {
+            proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+            console.log(2323);
+            return false;
         }
-      });
     }
-
-
+    }
 
     if (form.value.arriveAmount > form.value.contractAmount) {
       proxy.$modal.msgError("实际收款金额不能大于合同收款金额");

+ 196 - 169
src/views/business/production/archiveTicket/form.vue

@@ -25,9 +25,10 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="账期" required>
+            <el-form-item label="账期">
               <el-select v-model="form.currentMonth" style="width: 100%" @change="changeMonthHandle">
-                <el-option v-for="item in months" :key="item.id" :label="`${item.year}-${item.month}`" :value="item.id" />
+                <el-option v-for="item in months" :key="item.id" :label="`${item.year}-${item.month}`"
+                  :value="item.id" />
               </el-select>
             </el-form-item>
           </el-col>
@@ -49,13 +50,17 @@
               <el-col v-if="files.length === 0">
                 <el-empty description="没有数据" />
               </el-col>
-              <el-col v-for="(o, index) in files" :key="o.UUID" :span="8" style="margin-bottom: 10px; position: relative">
+              <el-col v-for="(o, index) in files" :key="o.UUID" :span="8"
+                style="margin-bottom: 10px; position: relative">
                 <el-card :body-style="{ padding: '0px' }">
-                  <img :src="`${baseUrl}${o.fileUrl}`" class="image" style="max-width: 100%; height: 200px" />
+                  <!-- <img :src="`${baseUrl}${o.fileUrl}`" class="image" style="max-width: 100%; height: 200px" @click="handleImageView(o.fileUrl)" /> -->
+                  <el-image :src="`${baseUrl}${o.fileUrl}`" class="image" style="max-width: 100%; height: 200px"
+                    :preview-teleported="true" fit="contain" :preview-src-list="srcList"
+                    @click="vbs(baseUrl + o.fileUrl)" />
                   <div style="padding: 14px">
                     <!-- <span>好吃的汉堡</span> -->
                     <div class="bottom clearfix">
-                      <el-form-item label="票据类型">
+                      <el-form-item label="票据类型" prop="typeId">
                         <el-select v-model="o.typeId">
                           <el-option v-for="i in ticket_type" :key="i.value" :value="i.value" :label="i.label" />
                         </el-select>
@@ -74,181 +79,203 @@
   </el-dialog>
 </template>
 <script setup>
-import { reactive } from "vue";
-import {
-  listFiles,
-  saveTickets,
-} from "@/api/business/production/archiveTicket";
-import { uploadFile } from "@/api/tool/file";
-const { proxy } = getCurrentInstance();
+  import { reactive } from "vue";
+  import {
+    listFiles,
+    saveTickets,
+  } from "@/api/business/production/archiveTicket";
+  import { uploadFile } from "@/api/tool/file";
+  const { proxy } = getCurrentInstance();
+  const { ticket_type } = proxy.useDict("ticket_type");
 
-const { ticket_type } = proxy.useDict("ticket_type");
-
-const props = defineProps({
-  getList: {
-    type: Function,
-    default: () => { },
-  },
-  width: {
-    type: String,
-    default: "800px",
-  },
-});
-const { getList, width } = toRefs(props);
-
-// import api from '@/api/biz/fileStorage'
-const data = reactive({
-  visible: false,
-  list: [],
-  total: 0,
-  query: {
-    name: "",
+  const formRules = ref({
+    typeId: [
+      { required: true, message: '请选择票据类型', trigger: 'change' }
+    ]
+  });
+  const props = defineProps({
+    getList: {
+      type: Function,
+      default: () => { },
+    },
+    width: {
+      type: String,
+      default: "800px",
+    },
+  });
+  const { getList, width } = toRefs(props);
+  const srcList = ref([
+    "https://elevator4s-oss.oss-cn-hangzhou.aliyuncs.com/2021/05/07/b632db6a837f46e0950670277fa9e5e5multipartFile.png"
+  ]);
+  // import api from '@/api/biz/fileStorage'
+  const data = reactive({
+    visible: false,
+    list: [],
     total: 0,
-    pageSize: 15,
-    pageNum: 1,
-  },
-  files: [],
-  months: [],
-  form: {},
-  selection: [],
-  baseUrl: import.meta.env.VITE_APP_BASE_API,
-  options: {},
-});
-const {
-  visible,
-  list,
-  query,
-  selection,
-  baseUrl,
-  options,
-  total,
-  files,
-  form,
-  months,
-} = toRefs(data);
+    query: {
+      name: "",
+      total: 0,
+      pageSize: 15,
+      pageNum: 1,
+    },
+    files: [],
+    months: [],
+    form: {},
+    selection: [],
+    baseUrl: import.meta.env.VITE_APP_BASE_API,
+    options: {},
+  });
+  const {
+    visible,
+    list,
+    query,
+    selection,
+    baseUrl,
+    options,
+    total,
+    files,
+    form,
+    months,
+  } = toRefs(data);
+
+  function open(arg) {
+    visible.value = true;
+    form.value = arg;
+    form.value.currentMonth = `${form.value.year}-${form.value.month}`;
+    options.value = arg;
+    loadData();
+  }
+  /**
+   * 对话框关闭 事件
+   */
+  function close() {
+    visible.value = false;
+  }
+  function handleImageView(fileUrl) {
+    window.open(`${baseUrl.value}${fileUrl}`);
+    // currentFileList.value = [`${baseUrl.value}${fileUrl}`];
+    // showViewer.value = true;
+  }
+  /**
+   * 加载数据
+   */
+  const loadData = async () => {
+    const res = await listFiles(form.value);
+    files.value = res.data.files;
+    months.value = res.data.months;
+    form.value.isFinished = res.data.finished.isFinished;
+  };
+  /**
+   * 列表checkbox列选择 事件
+   */
+  function handleSelectionChange(selection) {
+    selection.value = selection;
+  }
+  /**
+   * 搜索 事件
+   */
+  function handleSearch() {
+    loadData();
+  }
+  function openFile(attach) {
+    window.open(`${baseUrl.value}/${attach.fileUrl}`, attach.fileName);
+  }
 
-function open(arg) {
-  visible.value = true;
-  form.value = arg;
-  form.value.currentMonth = `${form.value.year}-${form.value.month}`;
-  options.value = arg;
-  loadData();
-}
-/**
- * 对话框关闭 事件
- */
-function close() {
-  visible.value = false;
-}
-/**
- * 加载数据
- */
-const loadData = async () => {
-  const res = await listFiles(form.value);
-  files.value = res.data.files;
-  months.value = res.data.months;
-  form.value.isFinished = res.data.finished.isFinished;
-};
-/**
- * 列表checkbox列选择 事件
- */
-function handleSelectionChange(selection) {
-  selection.value = selection;
-}
-/**
- * 搜索 事件
- */
-function handleSearch() {
-  loadData();
-}
-function openFile(attach) {
-  window.open(`${baseUrl.value}/${attach.fileUrl}`, attach.fileName);
-}
+  function upload(param) {
+    const formData = new FormData();
+    formData.append("file", param.file);
+    uploadFile(formData).then((res) => {
+      if (res.code === 200) {
+        const file = {};
+        file.fileName = res.newFileName;
+        file.url = res.url;
+        file.originalFileName = res.originalFilename;
+        file.fileUrl = res.fileName;
+        files.value.push(file);
+      }
+    });
+  }
 
-function upload(param) {
-  const formData = new FormData();
-  formData.append("file", param.file);
-  uploadFile(formData).then((res) => {
-    if (res.code === 200) {
-      const file = {};
-      file.fileName = res.newFileName;
-      file.url = res.url;
-      file.originalFileName = res.originalFilename;
-      file.fileUrl = res.fileName;
-      files.value.push(file);
+  function changeMonthHandle(item) {
+    const index = months.value.findIndex((v) => v.id === item);
+    if (index >= 0) {
+      const moment =
+        months.value.length > 0
+          ? proxy.moment(
+            `${months.value[index].year}-${months.value[index].month}`,
+            "YYYY-MM"
+          )
+          : null;
+      // console.log(months.value)
+      form.value.year =
+        moment != null ? proxy.moment(moment).format("YYYY") : null;
+      form.value.month =
+        moment != null ? proxy.moment(moment).format("MM") : null;
+    } else {
+      form.value.checkoutId = months.value.length > 0 ? months.value[0].id : 0;
+      const moment =
+        months.value.length > 0
+          ? proxy.moment(
+            `${months.value[0].year}-${months.value[0].month}`,
+            "YYYY-MM"
+          )
+          : null;
+      // console.log(months.value)
+      form.value.year =
+        moment != null ? proxy.moment(moment).format("YYYY") : null;
+      form.value.month =
+        moment != null ? proxy.moment(moment).format("MM") : null;
     }
-  });
-}
-
-function changeMonthHandle(item) {
-  const index = months.value.findIndex((v) => v.id === item);
-  if (index >= 0) {
-    const moment =
-      months.value.length > 0
-        ? proxy.moment(
-          `${months.value[index].year}-${months.value[index].month}`,
-          "YYYY-MM"
-        )
-        : null;
-    // console.log(months.value)
-    form.value.year =
-      moment != null ? proxy.moment(moment).format("YYYY") : null;
-    form.value.month =
-      moment != null ? proxy.moment(moment).format("MM") : null;
-  } else {
-    form.value.checkoutId = months.value.length > 0 ? months.value[0].id : 0;
-    const moment =
-      months.value.length > 0
-        ? proxy.moment(
-          `${months.value[0].year}-${months.value[0].month}`,
-          "YYYY-MM"
-        )
-        : null;
-    // console.log(months.value)
-    form.value.year =
-      moment != null ? proxy.moment(moment).format("YYYY") : null;
-    form.value.month =
-      moment != null ? proxy.moment(moment).format("MM") : null;
+    loadData();
+  }
+  function vbs(val) {
+    srcList.value = []
+    srcList.value.push(val)
   }
-  loadData();
-}
 
+  function handleBeforeUpload(file) {
 
-function handleBeforeUpload(file) {
+    if (file.type !== "image/bmp" && file.type !== "image/gif" && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/png' && file.type != 'image/tiff') {
+      proxy.$modal.msgError("请选择图片文件");
+      return false;
+    }
+    return true;
+  }
 
-  if (file.type !== "image/bmp" && file.type !== "image/gif" && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/png' && file.type != 'image/tiff') {
-    proxy.$modal.msgError("请选择图片文件");
-    return false;
+  function deleteHandle(index) {
+    proxy.$modal
+      .confirm("确定删除?")
+      .then(() => {
+        files.value.splice(index, 1);
+      })
+      .catch(() => {
+        proxy.$modal.msg("已取消删除");
+      });
   }
-  return true;
-}
 
-function deleteHandle(index) {
-  proxy.$modal
-    .confirm("确定删除?")
-    .then(() => {
-      files.value.splice(index, 1);
-    })
-    .catch(() => {
-      proxy.$modal.msg("已取消删除");
+  function handleSave() {
+    console.log(1111, files.value);
+    for (let i = 0; i < files.value.length; i++) {
+      const item = files.value[i];
+      if (item.typeId == null) {
+        proxy.$modal.msgError("票据类型不能为空");
+        return;
+      }
+    }
+    const file = {
+      companyId: form.value.companyId,
+      year: form.value.year,
+      month: form.value.month,
+      isFinished: form.value.isFinished,
+      files: files.value,
+    };
+    saveTickets(file).then((res) => {
+      getList.value();
+      close();
     });
-}
+  }
 
-function handleSave() {
-  const file = {
-    companyId: form.value.companyId,
-    year: form.value.year,
-    month: form.value.month,
-    isFinished: form.value.isFinished,
-    files: files.value,
-  };
-  saveTickets(file).then((res) => {
-    getList.value();
-    close();
+  defineExpose({
+    open,
   });
-}
-
-defineExpose({
-  open,
-});
-</script>
+</script>

+ 12 - 4
src/views/business/production/archiveTicket/view.vue

@@ -64,11 +64,14 @@
                 style="margin-bottom: 10px; position: relative"
               >
                 <el-card :body-style="{ padding: '0px' }">
-                  <img
+                  <!-- <img
                     :src="`${baseUrl}${o.fileUrl}`"
                     class="image"
                     style="max-width: 100%; height: 200px"
-                  />
+                  /> -->
+                  <el-image :src="`${baseUrl}${o.fileUrl}`" class="image" style="max-width: 100%; height: 200px"
+                  :preview-teleported="true" fit="contain" :preview-src-list="srcList"
+                  @click="vbs(baseUrl + o.fileUrl)" />
                   <div style="padding: 14px">
                     <div class="bottom clearfix">
                       <el-form-item label="票据类型">
@@ -138,7 +141,9 @@ const {
   form,
   months,
 } = toRefs(data);
-
+const srcList = ref([
+    "https://elevator4s-oss.oss-cn-hangzhou.aliyuncs.com/2021/05/07/b632db6a837f46e0950670277fa9e5e5multipartFile.png"
+  ]);
 function open(arg) {
   visible.value = true;
   form.value = arg;
@@ -249,7 +254,10 @@ function handleSave() {
     close();
   });
 }
-
+function vbs(val) {
+    srcList.value = []
+    srcList.value.push(val)
+  }
 defineExpose({
   open,
 });