hezhijie 1 päivä sitten
vanhempi
sitoutus
856e4237e8

+ 1 - 1
traceCodePackages/traceabilityReport/pages/reportExport/detail/index.vue

@@ -136,7 +136,7 @@
         </view>
       </view>
       <view v-if="showEmptyData" class="empty-data">
-        <EmptyView text="无相关数据" />
+        <EmptyView text="该时间段没有数据,请重新选择时间段" />
       </view>
     </view>
   </view>

+ 197 - 8
traceCodePackages/traceabilityReport/pages/reportExport/index.vue

@@ -205,10 +205,91 @@
           </view>
           <view class="report-export-create-modal-row">
             <text class="report-export-create-modal-label">其它客户</text>
-            <view class="report-export-create-modal-inputwrap">
-              <input class="report-export-dropdown-search-input" v-model="form.otherCustomer"
-                placeholder="请填写(多个客户用半角逗号隔开)" placeholder-class="report-export-dropdown-other-customer-input"
-                :disabled="modalType === 'read'" :style="{ color: '#666', padding: 0, border: 'none' }" />
+            <view
+              class="report-export-create-modal-inputwrap"
+              @click.stop="modalType !== 'read' && openDropdown('otherCustomer')"
+            >
+              <view class="report-export-create-modal-static" :style="{ maxHeight: 'auto', overflowY: 'visible' }">
+                <block v-if="getOtherCustomerArray().length">
+                  <view :style="{
+                    maxHeight: '100rpx',
+                    overflowY: 'auto',
+                    paddingRight: '40rpx',
+                  }">
+                    <text
+                      v-for="(name, i) in getOtherCustomerArray()"
+                      :key="'other-cust-tag-' + i"
+                      class="customer-chip"
+                    >
+                      {{ name }}
+                      <text
+                        class="customer-chip-close"
+                        @click.stop="
+                          modalType !== 'read' &&
+                          removeOtherCustomer(name)
+                        "
+                      >×</text>
+                    </text>
+                  </view>
+                </block>
+                <text v-else>请选择其它客户</text>
+                <text
+                  v-if="
+                    getOtherCustomerArray().length &&
+                    modalType !== 'read'
+                  "
+                  class="customer-clear-all"
+                  @click.stop="modalType !== 'read' && clearAllOtherCustomers()"
+                >×</text>
+              </view>
+              <view class="report-export-input-arrow" v-if="modalType !== 'read'"></view>
+              <view
+                class="report-export-create-modal-dropdown"
+                v-if="dropdown.otherCustomer"
+                @click.stop
+                :style="[
+                  dropdownPosStyle(),
+                  { maxHeight: 'none', overflow: 'visible' },
+                ]"
+              >
+                <view class="report-export-dropdown-search-row">
+                  <input
+                    class="report-export-dropdown-search-input"
+                    v-model="otherCustomerSearch"
+                    :disabled="modalType === 'read'"
+                    @input="modalType !== 'read' && onInput('otherCustomer')"
+                    @focus="onSearchFocus"
+                    @blur="onSearchBlur"
+                    placeholder="请输入客户名称"
+                  />
+                </view>
+                <scroll-view class="report-export-create-modal-dropdown-list" scroll-y>
+                  <view
+                    class="report-export-create-modal-dropdown-item"
+                    :class="{
+                      'report-export-selected': isOtherCustomerSelected(op),
+                    }"
+                    v-for="(op, i) in otherCustomers"
+                    :key="'other-cust-' + i"
+                    @click.stop="
+                      modalType !== 'read' && pickOption('otherCustomer', op)
+                    "
+                  >{{ op }}</view>
+                  <view
+                    v-if="!otherCustomerSearch.trim()"
+                    class="report-export-create-modal-dropdown-item"
+                  >请输入客户名称以搜索客户</view>
+                  <view
+                    v-else-if="otherCustomers.length === 0 && !otherCustomerLoading"
+                    class="report-export-create-modal-dropdown-item"
+                  >未查找到该客户</view>
+                  <view v-if="otherCustomerLoading" class="report-export-loading-row">
+                    <view class="report-export-loading-wrapper">
+                      <image class="report-export-loading-icon" src="../../../static/images/loading.png" />
+                    </view>
+                  </view>
+                </scroll-view>
+              </view>
             </view>
           </view>
           <view class="report-export-create-modal-row">
@@ -468,6 +549,7 @@ export default {
         region: false,
         customerType: false,
         customer: false,
+        otherCustomer: false,
         product: false,
         pkgSpec: false,
       },
@@ -515,6 +597,10 @@ export default {
       modalType: "",
       dropdownUpward: false,
       customerSearch: "",
+      otherCustomerSearch: "",
+      otherCustomers: [],
+      otherCustomerLoading: false,
+      otherCustomerDebounceTimer: null,
       currentItem: {},
       emailModalOpen: false,
       emailForm: {
@@ -682,6 +768,40 @@ export default {
         this.customerLoading = false;
       });
     },
+    getOtherCustomerOptions() {
+      const keyword = String(this.otherCustomerSearch || "").trim();
+      if (!keyword) {
+        if (!keyword) this.otherCustomers = [];
+        return;
+      }
+      this.otherCustomerLoading = true;
+      request(
+        "/report/getEntName?entName=" + encodeURIComponent(keyword),
+        {
+          entName: keyword,
+          path: "/reportExport/index.vue",
+        },
+        "get",
+      ).then((res) => {
+        if (res.code == 200) {
+          const raw = Array.isArray(res.data)
+            ? res.data
+            : Array.isArray(res.data?.list)
+              ? res.data.list
+              : [];
+          const names = raw
+            .map((item) =>
+              typeof item === "string" ? item : item?.entName || item?.customerName || "",
+            )
+            .map((name) => String(name || "").trim())
+            .filter(Boolean);
+          this.otherCustomers = Array.from(new Set(names));
+        } else {
+          this.otherCustomers = [];
+        }
+        this.otherCustomerLoading = false;
+      });
+    },
     initList() {
       const info = uni.getSystemInfoSync();
       const h = info.windowHeight || 800;
@@ -864,6 +984,13 @@ export default {
         region: "",
         product: "",
       };
+      this.otherCustomerSearch = "";
+      this.otherCustomers = [];
+      this.otherCustomerLoading = false;
+      if (this.otherCustomerDebounceTimer) {
+        clearTimeout(this.otherCustomerDebounceTimer);
+        this.otherCustomerDebounceTimer = null;
+      }
       this.dateRange = [];
       if (this.computeTimer) {
         clearTimeout(this.computeTimer);
@@ -934,12 +1061,18 @@ export default {
         this.dateRange.length === 2 &&
         this.dateRange[0] &&
         this.dateRange[1];
-      let customerOk = Array.isArray(f.customer)
+      const hasSelectedCustomer = Array.isArray(f.customer)
         ? f.customer.length > 0
         : !!f.customer;
-      customerOk = customerOk || f.otherCustomer;
+      const hasOtherCustomer = !!String(f.otherCustomer || "").trim();
+      const hasOtherCustomerCode = !!String(f.otherCustomerCode || "").trim();
+      const customerOk =
+        hasSelectedCustomer || hasOtherCustomer || hasOtherCustomerCode;
       if (!customerOk) {
-        uni.showToast({ title: "请选择至少一个客户或其他客户", icon: "none" });
+        uni.showToast({
+          title: "请至少填写客户、其它客户、其它客户信用代码中的一项",
+          icon: "none",
+        });
         return false;
       }
       if (!f.product?.physicName) {
@@ -1007,6 +1140,26 @@ export default {
       }
       if (k === "product") {
         this.initProductList("create");
+        return;
+      }
+      if (k === "otherCustomer") {
+        const keyword = String(this.otherCustomerSearch || "").trim();
+        if (!keyword) {
+          this.otherCustomers = [];
+          this.otherCustomerLoading = false;
+          if (this.otherCustomerDebounceTimer) {
+            clearTimeout(this.otherCustomerDebounceTimer);
+            this.otherCustomerDebounceTimer = null;
+          }
+          return;
+        }
+        // 输入后先进入 loading,避免先闪“未查找到该客户”
+        this.otherCustomerLoading = true;
+        if (this.otherCustomerDebounceTimer)
+          clearTimeout(this.otherCustomerDebounceTimer);
+        this.otherCustomerDebounceTimer = setTimeout(() => {
+          this.getOtherCustomerOptions();
+        }, 500);
       }
     },
     closeDropdownAll() {
@@ -1014,6 +1167,7 @@ export default {
         region: false,
         customerType: false,
         customer: false,
+        otherCustomer: false,
         product: false,
         pkgSpec: false,
       };
@@ -1088,6 +1242,9 @@ export default {
       if (k === "product") {
         this.initProductList("create");
       }
+      if (k === "otherCustomer" && !String(this.otherCustomerSearch || "").trim()) {
+        this.otherCustomers = [];
+      }
     },
     toggleDropdown(k) {
       this.dropdown[k] = !this.dropdown[k];
@@ -1103,6 +1260,21 @@ export default {
         }
         return;
       }
+      if (k === "otherCustomer") {
+        const name =
+          typeof v === "string"
+            ? v
+            : v?.entName || v?.customerName || "";
+        const selected = this.getOtherCustomerArray();
+        const idx = selected.findIndex((item) => item === name);
+        if (idx === -1) {
+          selected.push(name);
+        } else {
+          selected.splice(idx, 1);
+        }
+        this.form.otherCustomer = selected.join(",");
+        return;
+      }
       this.form[k] = v;
       if (k === "product") {
         this.form.pkgSpec = "";
@@ -1123,6 +1295,22 @@ export default {
     clearAllCustomers() {
       this.form.customer = [];
     },
+    getOtherCustomerArray() {
+      return String(this.form.otherCustomer || "")
+        .split(",")
+        .map((i) => i.trim())
+        .filter(Boolean);
+    },
+    isOtherCustomerSelected(name) {
+      return this.getOtherCustomerArray().includes(name);
+    },
+    removeOtherCustomer(name) {
+      const arr = this.getOtherCustomerArray().filter((i) => i !== name);
+      this.form.otherCustomer = arr.join(",");
+    },
+    clearAllOtherCustomers() {
+      this.form.otherCustomer = "";
+    },
     filteredOptions(k, type) {
       const arr = this.options[k] || [];
       let q = "";
@@ -1284,7 +1472,8 @@ export default {
       const url = "/report/sendemail";
       request(url, {
         taskId: this.currentItem?.id,
-        emailAddress: email + "@999.com.cn",
+        // emailAddress: email + "@999.com.cn",
+        emailAddress: "hezhijie@dotouch.tech",
         path: "reportExport/index.vue",
       }).then((res) => {
         uni.hideLoading();