ScanRateTable.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. <template>
  2. <view
  3. class="section"
  4. :style="{
  5. position: 'relative',
  6. zIndex: dropdownOpen || dropdownRegionOpen ? 9 : 'auto',
  7. }"
  8. >
  9. <view v-if="showHeader" class="section-header">
  10. <text class="section-title">{{ title }}</text>
  11. <view :style="{ display: 'flex' }">
  12. <view
  13. v-if="showSelector && tableType === 'variety'"
  14. class="selector-wrap"
  15. >
  16. <view class="selector" @click.stop="toggleDropdownRegion">
  17. <text class="selector-text">{{
  18. region?.regionCode ? region.regionName : "选择片区"
  19. }}</text>
  20. <text
  21. class="selector-arrow"
  22. :class="{ open: dropdownRegionOpen }"
  23. ></text>
  24. </view>
  25. <view
  26. class="dropdown"
  27. v-show="dropdownRegionOpen"
  28. :style="
  29. dropdownDirection === 'top'
  30. ? { top: 'auto', bottom: '48rpx' }
  31. : {}
  32. "
  33. @click.stop
  34. >
  35. <view class="dropdown-search-bar">
  36. <input
  37. class="dropdown-search-input"
  38. v-model="regionSearchText"
  39. @input="onRegionSearch"
  40. placeholder="搜索..."
  41. />
  42. </view>
  43. <scroll-view
  44. scroll-y="true"
  45. class="dropdown-scroll-view"
  46. lower-threshold="80"
  47. @scrolltolower="loadMoreRegions"
  48. >
  49. <view
  50. class="dropdown-item"
  51. v-for="(p, i) in regionList"
  52. :key="p.regionCode || i"
  53. :style="
  54. p.regionCode === region?.regionCode ||
  55. (!region?.regionCode && i == 0)
  56. ? {
  57. backgroundColor: '#2c69ff',
  58. color: '#fff',
  59. }
  60. : {}
  61. "
  62. @click.stop="selectProduct('region', p)"
  63. >{{ p.regionName || p }}</view
  64. >
  65. <view
  66. v-if="regionList.length === 0"
  67. class="dropdown-item"
  68. style="text-align: center; color: #999"
  69. >暂无数据
  70. </view>
  71. </scroll-view>
  72. </view>
  73. </view>
  74. <view v-if="showSelector" class="selector-wrap">
  75. <view class="selector" @click.stop="toggleDropdown">
  76. <text class="selector-text">{{
  77. product?.drugEntBaseInfoId ? product.physicName : "选择品种"
  78. }}</text>
  79. <text class="selector-arrow" :class="{ open: dropdownOpen }"></text>
  80. </view>
  81. <view
  82. class="dropdown"
  83. v-show="dropdownOpen"
  84. :style="
  85. dropdownDirection === 'top'
  86. ? {
  87. top: 'auto',
  88. bottom: '48rpx',
  89. }
  90. : {}
  91. "
  92. @click.stop
  93. >
  94. <view class="dropdown-search-bar">
  95. <input
  96. class="dropdown-search-input"
  97. v-model="productSearchText"
  98. @input="onProductSearch"
  99. placeholder="搜索..."
  100. />
  101. </view>
  102. <scroll-view
  103. scroll-y="true"
  104. class="dropdown-scroll-view"
  105. lower-threshold="80"
  106. @scrolltolower="loadMoreProducts"
  107. >
  108. <view
  109. class="dropdown-item"
  110. v-for="(p, i) in productList"
  111. :key="p.drugEntBaseInfoId || i"
  112. :style="
  113. p.drugEntBaseInfoId === product?.drugEntBaseInfoId ||
  114. (!product?.drugEntBaseInfoId && i == 0)
  115. ? {
  116. backgroundColor: '#2c69ff',
  117. color: '#fff',
  118. }
  119. : {}
  120. "
  121. @click.stop="selectProduct('product', p)"
  122. >{{ p.physicName }}</view
  123. >
  124. <view
  125. v-if="productList.length === 0"
  126. class="dropdown-item"
  127. style="text-align: center; color: #999"
  128. >暂无数据
  129. </view>
  130. </scroll-view>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. <view
  136. class="table-scroll-x"
  137. :style="{
  138. height:
  139. tableHeightAuto || list.length < 7
  140. ? 'auto'
  141. : tableBodyHeight + 80 + 'rpx',
  142. maxHeight: tableHeightAuto,
  143. }"
  144. >
  145. <scroll-view
  146. class="no-scrollbar"
  147. :style="{ height: '100%' }"
  148. scroll-x="true"
  149. scroll-y="true"
  150. enhanced
  151. :show-scrollbar="false"
  152. @scrolltolower="onScrollToLower"
  153. >
  154. <view class="card" :style="{ width: tableWidth }">
  155. <view
  156. class="table-header"
  157. :style="{
  158. position: 'sticky',
  159. top: '0',
  160. zIndex: 10,
  161. fontWeight: headerBold ? 'bold' : 'normal',
  162. }"
  163. >
  164. <view
  165. v-for="(col, ci) in columnList"
  166. :key="getUid()"
  167. class="cell"
  168. :style="{
  169. ...headerCellStyle(ci, col),
  170. }"
  171. >
  172. <view
  173. v-if="isPlainTitle(col.title)"
  174. :style="{
  175. display: 'flex',
  176. alignItems: 'center',
  177. position: 'relative',
  178. }"
  179. >
  180. <text>{{ col.title }}</text>
  181. <uni-icons
  182. v-if="col.tooltip"
  183. type="help"
  184. size="16"
  185. color="#2c69ff"
  186. @tap.stop.prevent="toggleHeaderTooltip(ci)"
  187. ></uni-icons>
  188. <view
  189. v-if="headerTooltip[ci]"
  190. class="header-tooltip-wrap"
  191. @click.stop
  192. >
  193. <view class="header-tooltip">{{ col.tooltip }}</view>
  194. <view class="header-tooltip-arrow"></view>
  195. </view>
  196. </view>
  197. <rich-text v-else :nodes="titleNodes(col.title)" />
  198. </view>
  199. </view>
  200. <view v-if="!loading && list && list.length > 0" class="table-body">
  201. <template>
  202. <view class="row" v-for="(item, i) in list" :key="getUid()">
  203. <view
  204. v-for="(col, ci) in columnList"
  205. :key="getUid()"
  206. class="cell"
  207. :class="{
  208. underline: col.underline,
  209. striped: striped && (i + 1) % 2 === 0,
  210. }"
  211. :style="bodyCellStyle(ci, col)"
  212. @click="handleClick(item, col)"
  213. >{{ renderCell(item, col) }}</view
  214. >
  215. </view>
  216. <view class="row loading-row" v-if="hasmore">
  217. <view class="loading-wrapper">
  218. <image class="loading-icon" :src="loadingImg" />
  219. </view>
  220. </view>
  221. <view
  222. class="row"
  223. v-if="showSummary"
  224. :style="{
  225. position: 'sticky',
  226. bottom: '0',
  227. zIndex: 5,
  228. backgroundColor: '#fff',
  229. borderTop: '1rpx solid #eef0f4',
  230. color: summaryFontColor,
  231. }"
  232. >
  233. <view
  234. v-for="(col, ci) in columnList"
  235. :key="getUid()"
  236. class="cell"
  237. :style="{
  238. ...bodyCellStyle(ci, col),
  239. fontWeight: summaryBold ? 'bold' : 'normal',
  240. }"
  241. >{{ getSummary(col, ci) }}</view
  242. >
  243. </view>
  244. </template>
  245. </view>
  246. </view>
  247. <view
  248. v-if="loading"
  249. class="no-data-placeholder"
  250. :style="{ height: 'auto' }"
  251. >
  252. <view class="row loading-row">
  253. <view class="loading-wrapper">
  254. <image class="loading-icon" :src="loadingImg" />
  255. </view>
  256. </view>
  257. </view>
  258. <view
  259. v-if="!loading && (!list || list.length === 0)"
  260. class="no-data-placeholder"
  261. >
  262. <EmptyView />
  263. </view>
  264. </scroll-view>
  265. <view
  266. v-if="loading"
  267. class="no-data"
  268. :style="{ height: 'auto', top: cellHeight }"
  269. >
  270. <view class="row loading-row">
  271. <view class="loading-wrapper">
  272. <image class="loading-icon" :src="loadingImg" />
  273. </view>
  274. </view>
  275. </view>
  276. <view
  277. v-if="!loading && (!list || list.length === 0)"
  278. class="no-data"
  279. :style="{ top: cellHeight }"
  280. >
  281. <EmptyView />
  282. </view>
  283. </view>
  284. </view>
  285. </template>
  286. <script>
  287. import EmptyView from "../../../../wigets/empty.vue";
  288. import loadingImg from "../../../../static/images/loading.png";
  289. import { getUid } from "../../../../utils/utils.js";
  290. import request from "../../../../request/index.js";
  291. import Select from "../../../../wigets/select.vue";
  292. export default {
  293. name: "ScanRateTable",
  294. components: { EmptyView, Select },
  295. props: {
  296. params: {
  297. type: Object,
  298. default: null,
  299. },
  300. scanType: { type: String, default: "1" },
  301. api: {
  302. type: String,
  303. default: "",
  304. },
  305. tableType: { type: String, default: "customer" },
  306. title: { type: String, default: "客户扫码率" },
  307. showSelector: { type: Boolean, default: true },
  308. showHeader: { type: Boolean, default: true },
  309. dropdownDirection: { type: String, default: "bottom" },
  310. showSummary: { type: Boolean, default: true },
  311. striped: { type: Boolean, default: true },
  312. summaryStructure: {
  313. type: Array,
  314. default: () => [
  315. {
  316. key: "totalInRate",
  317. title: "入库扫码率",
  318. unit: "%",
  319. },
  320. {
  321. key: "totalOutRate",
  322. title: "出库扫码率",
  323. unit: "%",
  324. },
  325. {
  326. key: "totalSelfExaminationRate",
  327. title: "自验证率",
  328. unit: "%",
  329. },
  330. ],
  331. },
  332. summaryBold: { type: Boolean, default: false },
  333. summaryFontColor: {
  334. type: String,
  335. default: "#2c69ff",
  336. },
  337. initial: { type: Array, default: () => [] },
  338. products: { type: Array, default: () => [] },
  339. regions: { type: Array, default: () => [] },
  340. cellHeight: {
  341. type: String,
  342. default: "76rpx",
  343. },
  344. headerFontSize: {
  345. type: String,
  346. default: "32rpx",
  347. },
  348. headerBold: {
  349. type: Boolean,
  350. default: true,
  351. },
  352. bodyFontSize: {
  353. type: String,
  354. default: "32rpx",
  355. },
  356. bodyFontColor: {
  357. type: String,
  358. default: "",
  359. },
  360. //若需要横向滚动且左侧固定,则tableWidth需等于columns所有width之和(可以略小于)
  361. tableWidth: {
  362. type: String,
  363. default: "100%",
  364. },
  365. tableHeightAuto: {
  366. type: Boolean,
  367. default: false,
  368. },
  369. columns: {
  370. type: Array,
  371. default: () => [
  372. {
  373. key: "regionName",
  374. title: "区域",
  375. underline: true,
  376. fixed: true,
  377. width: "",
  378. },
  379. {
  380. key: "outScanRate",
  381. title: "出库扫码率",
  382. fixed: false,
  383. width: "",
  384. tooltip:
  385. "客户出库扫码量(与下游入库单中相同的追溯码)/下游企业入库扫码量",
  386. unit: "%",
  387. },
  388. {
  389. key: "inScanRate",
  390. title: "入库扫码率",
  391. fixed: false,
  392. width: "",
  393. tooltip:
  394. "客户入库扫码量(与上游出库单中相同的追溯码)/上游企业出库扫码量",
  395. unit: "%",
  396. },
  397. {
  398. key: "selfExaminationRate",
  399. title: "自验证率",
  400. fixed: false,
  401. width: "",
  402. tooltip: "客户出库扫码量(与入库单中相同的追溯码)/入库扫码量",
  403. unit: "%",
  404. },
  405. ],
  406. },
  407. },
  408. data() {
  409. return {
  410. dropdownOpen: false,
  411. dropdownRegionOpen: false,
  412. list: [],
  413. totalCount: 0,
  414. hasmore: true,
  415. loading: true,
  416. fetchLoading: false,
  417. loadingImg,
  418. product: null,
  419. region: null,
  420. tablePage: 1,
  421. tablePageSize: 10,
  422. summaryData: [],
  423. headerTooltip: {},
  424. regionSearchText: "",
  425. productSearchText: "",
  426. regionList: [],
  427. productList: [],
  428. };
  429. },
  430. computed: {
  431. filteredRegions() {
  432. if (!this.regionSearchText) return this.regions;
  433. const lower = this.regionSearchText.toLowerCase();
  434. return this.regions.filter(
  435. (r) =>
  436. (r.regionName || r.name || r || "")
  437. .toString()
  438. .toLowerCase()
  439. .indexOf(lower) > -1,
  440. );
  441. },
  442. filteredProducts() {
  443. if (!this.productSearchText) return this.products;
  444. const lower = this.productSearchText.toLowerCase();
  445. return this.products.filter(
  446. (p) => (p.physicName || "").toLowerCase().indexOf(lower) > -1,
  447. );
  448. },
  449. tableBodyHeight() {
  450. return 6 * 80;
  451. },
  452. columnList() {
  453. if (this.params) {
  454. const type = this.params?.type;
  455. if (type === "1" || type === "2")
  456. return this.columns.filter((i) => i.key !== "selfExaminationRate");
  457. }
  458. return this.columns;
  459. },
  460. },
  461. watch: {
  462. dropdownRegionOpen(val) {
  463. if (val) {
  464. this.regionSearchText = "";
  465. this.initRegionList();
  466. }
  467. },
  468. dropdownOpen(val) {
  469. if (val) {
  470. this.productSearchText = "";
  471. this.initProductList();
  472. }
  473. },
  474. product(val) {
  475. this.resetFetch();
  476. },
  477. region: {
  478. handler(val) {
  479. this.resetFetch();
  480. },
  481. deep: true,
  482. },
  483. params: {
  484. handler(newVal, oldVal) {
  485. if (
  486. newVal !== oldVal &&
  487. JSON.stringify(newVal) === JSON.stringify(oldVal)
  488. )
  489. return;
  490. this.resetFetch();
  491. },
  492. deep: true,
  493. },
  494. products: {
  495. handler(newVal, oldVal) {
  496. if (this.dropdownOpen) {
  497. this.initProductList();
  498. }
  499. },
  500. deep: true,
  501. },
  502. regions: {
  503. handler(newVal, oldVal) {
  504. if (this.dropdownRegionOpen) {
  505. this.initRegionList();
  506. }
  507. },
  508. deep: true,
  509. },
  510. },
  511. created() {
  512. // this.fetchLoading = false;
  513. // this.isLoading = false;
  514. // this.loading = false;
  515. // this.list =
  516. // this.initial && this.initial.length ? this.initial : this.genRows(7);
  517. // if (this.list.length > this.totalCount) {
  518. // this.list = this.list.slice(0, this.totalCount);
  519. // }
  520. // if (!this.showHeader) {
  521. // this.fetchList();
  522. // } else {
  523. // Promise.all([this.getProviceList(), this.getDrugInfoName()]).then(
  524. // () => { }
  525. // );
  526. // }
  527. this.fetchList();
  528. },
  529. methods: {
  530. renderCell(item, col) {
  531. if (!item[col.key]) return "--";
  532. const reg = /rate/i;
  533. if (reg.test(col.key))
  534. return Math.floor(Number(item[col.key])) + (col.unit || "");
  535. return item[col.key];
  536. },
  537. initRegionList() {
  538. this.regionList = this.filteredRegions.slice(0, 10);
  539. },
  540. loadMoreRegions(e) {
  541. if (this.regionList.length >= this.filteredRegions.length) return;
  542. const currentLen = this.regionList.length;
  543. const more = this.filteredRegions.slice(currentLen, currentLen + 10);
  544. this.regionList = this.regionList.concat(more);
  545. },
  546. onRegionSearch() {
  547. this.initRegionList();
  548. },
  549. initProductList() {
  550. this.productList = this.filteredProducts.slice(0, 10);
  551. },
  552. loadMoreProducts() {
  553. if (this.productList.length >= this.filteredProducts.length) return;
  554. const currentLen = this.productList.length;
  555. const more = this.filteredProducts.slice(currentLen, currentLen + 10);
  556. this.productList = this.productList.concat(more);
  557. },
  558. onProductSearch() {
  559. this.initProductList();
  560. },
  561. getUid,
  562. getSummary(col, ci) {
  563. if (ci == 0) return "合计";
  564. return Math.floor(Number(this.summaryData[ci])) + (col.unit || "");
  565. },
  566. closeAllTooltip() {
  567. this.headerTooltip = {};
  568. },
  569. toggleHeaderTooltip(i) {
  570. const value = !this.headerTooltip[i];
  571. this.headerTooltip = {};
  572. this.$set(this.headerTooltip, i, value);
  573. },
  574. // getUid(len = 16) {
  575. // const ts = Date.now().toString(36);
  576. // const rand = Math.random().toString(36).slice(2);
  577. // return (ts + rand).slice(0, len);
  578. // },
  579. // getProviceList() {
  580. // request('/common/getProviceList', {
  581. // path: 'customerScanningRate/wigets/ScanRateTable.vue',
  582. // }).then(res => {
  583. // if (res.code == 200) {
  584. // const _data = res.data;
  585. // this.regions = _data;
  586. // this.region = this.regions[0];
  587. // }
  588. // })
  589. // },
  590. // getDrugInfoName() {
  591. // request('/bills/getDrugInfoName', {
  592. // path: 'customerScanningRate/wigets/ScanRateTable.vue',
  593. // }).then(res => {
  594. // if (res.code == 200) {
  595. // const _data = res.data;
  596. // this.products = _data;
  597. // this.product = this.products[0];
  598. // }
  599. // })
  600. // },
  601. toggleDropdown() {
  602. if (this.fetchLoading) return;
  603. const next = !this.dropdownOpen;
  604. if (next) this.$emit("dropdown-open", this);
  605. this.dropdownOpen = next;
  606. },
  607. toggleDropdownRegion() {
  608. if (this.fetchLoading) return;
  609. const next = !this.dropdownRegionOpen;
  610. if (next) this.$emit("dropdown-open", this);
  611. this.dropdownRegionOpen = next;
  612. },
  613. selectProduct(type, p) {
  614. // this.$emit("change-product", p);
  615. if (type === "product") {
  616. this.product = p;
  617. this.dropdownOpen = false;
  618. } else if (type === "region") {
  619. this.region = p;
  620. this.dropdownRegionOpen = false;
  621. }
  622. },
  623. closeDropdown() {
  624. this.dropdownOpen = false;
  625. this.dropdownRegionOpen = false;
  626. },
  627. // genRows(n) {
  628. // const regions = ["广东", "广西", "湖南", "湖北", "四川", "浙江", "江苏"];
  629. // const res = [];
  630. // for (let i = 0; i < n; i++) {
  631. // const r = regions[i % regions.length];
  632. // res.push({
  633. // regionName: r,
  634. // outScanRate: `${(95 + (i % 5) * 0.5).toFixed(1)}%`,
  635. // inScanRate: `${(94 + (i % 5) * 0.6).toFixed(1)}%`,
  636. // });
  637. // }
  638. // return res;
  639. // },
  640. onScrollToLower(e) {
  641. if (e?.detail?.direction === "right") return;
  642. // if (!Array.isArray(this.list)) this.list = [];
  643. // if (this.list.length - 1 >= this.totalCount) return;
  644. // if (this.isLoading) return;
  645. // this.isLoading = true;
  646. // const remain = this.totalCount - this.list.length;
  647. // const toAdd = Math.min(7, remain);
  648. // setTimeout(() => {
  649. // if (this.list.length < this.totalCount) {
  650. // const more = this.genRows(toAdd);
  651. // this.list = this.list.concat(more);
  652. // }
  653. // this.isLoading = false;
  654. // }, 1000);
  655. this.fetchList();
  656. },
  657. resetFetch() {
  658. this.tablePage = 1;
  659. this.list = [];
  660. this.loading = true;
  661. this.hasmore = true;
  662. this.fetchList();
  663. },
  664. fetchList() {
  665. if (this._fetchDebounceTimer) clearTimeout(this._fetchDebounceTimer);
  666. const delay = 500;
  667. this._fetchDebounceTimer = setTimeout(() => {
  668. if (!this.hasmore) {
  669. setTimeout(() => {
  670. this.fetchLoading = false;
  671. this.loading = false;
  672. }, 500);
  673. return;
  674. }
  675. if (this.fetchLoading) return;
  676. this.fetchLoading = true;
  677. request(this.api, {
  678. drugEntBaseInfoId: this.product
  679. ? this.product?.drugEntBaseInfoId || ""
  680. : "",
  681. regionCode: this.region ? this.region?.regionCode || "" : "",
  682. pageNum: this.tablePage,
  683. pageSize: this.tablePageSize,
  684. path: "customerScanningRate/wigets/ScanRateTable.vue",
  685. ...(this.params || {}),
  686. }).then((res) => {
  687. if (res.code == 200) {
  688. const _data = res.data || {};
  689. let pageInfo = _data || {};
  690. if (this.tableType !== "variety") {
  691. this.summaryData = [];
  692. this.summaryData[0] = undefined;
  693. this.summaryStructure.forEach((item) => {
  694. this.summaryData.push(_data[item.key] || "--");
  695. });
  696. pageInfo = _data?.pageInfo || {};
  697. }
  698. const { list, total } = pageInfo;
  699. this.totalCount = total || 0;
  700. if (this.list.length >= this.totalCount) {
  701. this.fetchLoading = false;
  702. this.hasmore = false;
  703. this.loading = false;
  704. return;
  705. }
  706. this.list = Array.isArray(list)
  707. ? [...this.list, ...list]
  708. : [...this.list];
  709. if (this.list.length < this.totalCount) {
  710. this.hasmore = true;
  711. this.tablePage++;
  712. } else {
  713. this.hasmore = false;
  714. }
  715. // this.list.push(this.list[0]);
  716. // this.list.push(this.list[0]);
  717. // this.list.push(this.list[0]);
  718. // this.list.push(this.list[0]);
  719. // this.list.push(this.list[0]);
  720. // this.list.push(this.list[0]);
  721. // this.list.push(this.list[0]);
  722. // this.list.push(this.list[0]);
  723. // this.list.push(this.list[0]);
  724. // this.list.push(this.list[0]);
  725. // this.list.push(this.list[0]);
  726. }
  727. this.fetchLoading = false;
  728. this.loading = false;
  729. });
  730. }, delay);
  731. },
  732. headerCellStyle(ci, col) {
  733. const base = this.cellBaseStyle(ci, col);
  734. base.height = this.cellHeight;
  735. base.fontSize = this.headerFontSize;
  736. base.position = "sticky";
  737. base.zIndex = 2;
  738. base.top = "0rpx";
  739. base.background = "#eaf2ff";
  740. // base.display = 'flex';
  741. // base.alignItems = 'center';
  742. // base.justifyContent = 'center';
  743. if (ci === 0) {
  744. base.zIndex = 3;
  745. }
  746. if (col.fixed) {
  747. base.left = this.stickyLeft(ci);
  748. }
  749. return base;
  750. },
  751. bodyCellStyle(ci, col) {
  752. const base = this.cellBaseStyle(ci, col);
  753. // base.lineHeight = this.cellHeight;
  754. base.padding = "12rpx";
  755. base.fontSize = this.bodyFontSize;
  756. if (this.bodyFontColor) {
  757. base.color = this.bodyFontColor;
  758. }
  759. if (col.fixed) {
  760. base.position = "sticky";
  761. base.left = this.stickyLeft(ci);
  762. base.zIndex = 2;
  763. }
  764. return base;
  765. },
  766. cellBaseStyle(ci, col) {
  767. const style = {};
  768. // style.height = this.cellHeight;
  769. if (col && col.width) {
  770. style.width = col.width;
  771. style.flex = `0 0 ${col.width}`;
  772. } else {
  773. style.flex = 1;
  774. }
  775. return style;
  776. },
  777. stickyLeft(ci) {
  778. const parts = [];
  779. for (let i = 0; i < ci; i++) {
  780. const c = this.columns[i];
  781. if (c && c.fixed && c.width) parts.push(c.width);
  782. }
  783. if (!parts.length) return "0rpx";
  784. if (parts.length === 1) return parts[0];
  785. return `calc(${parts.join(" + ")})`;
  786. },
  787. isPlainTitle(t) {
  788. return typeof t === "string" ? t.indexOf("<") === -1 : true;
  789. },
  790. titleNodes(t) {
  791. if (typeof t !== "string") return t;
  792. let html = String(t);
  793. html = html
  794. .replace(/<\s*view/g, "<div")
  795. .replace(/<\/\s*view\s*>/g, "</div>");
  796. html = html.replace(
  797. /:style=\"\{\s*textAlign:\s*'center'\s*\}\"/g,
  798. 'style="text-align:center;"',
  799. );
  800. return html;
  801. },
  802. handleClick(data, col) {
  803. if (
  804. this.tableType === "variety" ||
  805. this.tableType === "customerDetail" ||
  806. col.key !== "regionName"
  807. )
  808. return;
  809. uni.navigateTo({
  810. url:
  811. "/traceCodePackages/traceabilityReport/pages/customerScanningRate/detail/index?regionCode=" +
  812. data.regionCode +
  813. "&regionName=" +
  814. encodeURIComponent(data.regionName) +
  815. "&drugEntBaseInfoId=" +
  816. (data.druGentBaseInfoId || "") +
  817. "&physicName=" +
  818. encodeURIComponent(data.name || "") +
  819. "&scanType=" +
  820. this.scanType +
  821. (this.params.type ? "&type=" + this.params.type : ""),
  822. });
  823. },
  824. },
  825. };
  826. </script>
  827. <style scoped>
  828. .section {
  829. margin-top: 24rpx;
  830. transform: translate3d(0, 0, 0);
  831. }
  832. .section-header {
  833. position: relative;
  834. display: flex;
  835. align-items: center;
  836. justify-content: space-between;
  837. padding: 8rpx 8rpx;
  838. }
  839. .section-title {
  840. position: relative;
  841. font-size: 30rpx;
  842. font-weight: bold;
  843. color: #2c69ff;
  844. }
  845. .section-title::after {
  846. content: "";
  847. position: absolute;
  848. left: -20rpx;
  849. bottom: 13rpx;
  850. width: 8rpx;
  851. height: 50%;
  852. background: #2c69ff;
  853. border-radius: 10px;
  854. }
  855. .selector-wrap {
  856. position: relative;
  857. margin-right: 40rpx;
  858. }
  859. .selector {
  860. position: relative;
  861. display: flex;
  862. align-items: center;
  863. color: #2c69ff;
  864. padding-right: 30rpx;
  865. }
  866. .selector-text {
  867. font-size: 30rpx;
  868. max-width: 180rpx;
  869. overflow: hidden;
  870. white-space: nowrap;
  871. text-overflow: ellipsis;
  872. display: inline-block;
  873. }
  874. .selector-arrow {
  875. position: absolute;
  876. right: 0rpx;
  877. bottom: 14rpx;
  878. font-size: 30rpx;
  879. display: inline-block;
  880. width: 15rpx;
  881. height: 15rpx;
  882. border: 5rpx solid #2c69ff;
  883. border-top: none;
  884. border-left: none;
  885. transform-origin: 50% 50%;
  886. transform: rotate(45deg);
  887. transition: transform 0.2s;
  888. }
  889. .selector-arrow.open {
  890. bottom: 7rpx;
  891. transform: rotate(225deg);
  892. }
  893. .dropdown {
  894. position: absolute;
  895. right: 0rpx;
  896. top: 54rpx;
  897. width: 310rpx;
  898. max-height: 380rpx;
  899. background: #fff;
  900. border: 1rpx solid #eef0f4;
  901. border-radius: 12rpx;
  902. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
  903. z-index: 93;
  904. overflow: hidden;
  905. }
  906. .dropdown-search-bar {
  907. padding: 10rpx;
  908. border-bottom: 1rpx solid #f0f2f5;
  909. background: #fff;
  910. z-index: 94;
  911. }
  912. .dropdown-search-input {
  913. width: 100%;
  914. height: 60rpx;
  915. background: #f5f7fa;
  916. border-radius: 8rpx;
  917. padding: 0 20rpx;
  918. font-size: 28rpx;
  919. box-sizing: border-box;
  920. }
  921. .dropdown-scroll-view {
  922. flex: 1;
  923. width: 100%;
  924. max-height: 260rpx;
  925. /* Adjusted height to fit search bar */
  926. overflow-y: auto;
  927. }
  928. .dropdown-item {
  929. padding: 16rpx 24rpx;
  930. font-size: 28rpx;
  931. color: #333;
  932. text-wrap: wrap;
  933. }
  934. .dropdown-item + .dropdown-item {
  935. border-top: 1rpx solid #f0f2f5;
  936. }
  937. .table-scroll-x {
  938. position: relative;
  939. margin-top: 12rpx;
  940. width: 100%;
  941. min-height: 120rpx;
  942. border-radius: 16rpx;
  943. overflow: visible;
  944. }
  945. .card {
  946. background: #fff;
  947. font-size: 32rpx;
  948. }
  949. .table-header {
  950. display: flex;
  951. background: #eaf2ff;
  952. font-weight: bold;
  953. color: #2c69ff;
  954. border-top-left-radius: 16rpx;
  955. border-top-right-radius: 16rpx;
  956. }
  957. /* .table-body {
  958. margin-top: 8rpx;
  959. } */
  960. .row {
  961. display: flex;
  962. align-items: stretch;
  963. border-bottom: 1rpx solid #eef0f4;
  964. }
  965. .row:last-child,
  966. .row:nth-last-child(2) {
  967. border-bottom: none;
  968. }
  969. .loading-row {
  970. justify-content: flex-start;
  971. }
  972. .loading-wrapper {
  973. width: calc(100vw - 60rpx);
  974. height: 76rpx;
  975. display: flex;
  976. align-items: center;
  977. justify-content: center;
  978. position: sticky;
  979. top: 50%;
  980. left: 0;
  981. }
  982. .loading-icon {
  983. width: 40rpx;
  984. height: 40rpx;
  985. animation: spin 1s linear infinite;
  986. }
  987. @keyframes spin {
  988. from {
  989. transform: rotate(0deg);
  990. }
  991. to {
  992. transform: rotate(360deg);
  993. }
  994. }
  995. .cell {
  996. flex: 1;
  997. box-sizing: border-box;
  998. width: 0;
  999. box-sizing: border-box;
  1000. display: flex;
  1001. align-items: center;
  1002. justify-content: center;
  1003. /* text-align: center; */
  1004. word-break: break-all;
  1005. }
  1006. .table-body .cell {
  1007. background-color: #fff;
  1008. text-align: center;
  1009. }
  1010. .table-body .striped {
  1011. background: #f7f7f7;
  1012. }
  1013. .underline {
  1014. text-decoration: underline;
  1015. color: #2c69ff;
  1016. }
  1017. /* hide scrollbars for H5/App while preserving scroll behavior */
  1018. .no-scrollbar {
  1019. position: relative;
  1020. -ms-overflow-style: none;
  1021. scrollbar-width: none;
  1022. z-index: 2;
  1023. }
  1024. ::v-deep .no-scrollbar::-webkit-scrollbar {
  1025. display: none !important;
  1026. width: 0 !important;
  1027. height: 0 !important;
  1028. -webkit-appearance: none;
  1029. background: transparent;
  1030. }
  1031. .header-tooltip-wrap {
  1032. position: absolute;
  1033. top: 60rpx;
  1034. right: 0rpx;
  1035. z-index: 93;
  1036. }
  1037. .header-tooltip {
  1038. background: #000;
  1039. color: #fff;
  1040. border-radius: 8rpx;
  1041. padding: 8rpx 12rpx;
  1042. font-size: 24rpx;
  1043. width: 270rpx;
  1044. }
  1045. .header-tooltip-arrow {
  1046. position: absolute;
  1047. top: -11rpx;
  1048. right: 20rpx;
  1049. width: 0;
  1050. height: 0;
  1051. border-left: 10rpx solid transparent;
  1052. border-right: 10rpx solid transparent;
  1053. border-bottom: 12rpx solid #000;
  1054. margin: 0 auto;
  1055. }
  1056. .no-data-placeholder {
  1057. opacity: 0;
  1058. }
  1059. .no-data {
  1060. position: absolute;
  1061. top: 76rpx;
  1062. left: 0;
  1063. width: 100%;
  1064. z-index: 1;
  1065. }
  1066. </style>