ScanRateTable.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  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: "totalOutRate",
  317. title: "出库扫码率",
  318. unit: "%",
  319. },
  320. {
  321. key: "totalInRate",
  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. physicName: this.product ? this.product?.physicName || "" : "",
  679. regionCode: this.region ? this.region?.regionCode || "" : "",
  680. pageNum: this.tablePage,
  681. pageSize: this.tablePageSize,
  682. path: "customerScanningRate/wigets/ScanRateTable.vue",
  683. ...(this.params || {}),
  684. }).then((res) => {
  685. if (res.code == 200) {
  686. const _data = res.data || {};
  687. let pageInfo = _data || {};
  688. if (this.tableType !== "variety") {
  689. this.summaryData = [];
  690. this.summaryData[0] = undefined;
  691. this.summaryStructure.forEach((item) => {
  692. this.summaryData.push(_data[item.key] || "--");
  693. });
  694. pageInfo = _data?.pageInfo || {};
  695. }
  696. const { list, total } = pageInfo;
  697. this.totalCount = total || 0;
  698. if (this.list.length >= this.totalCount) {
  699. this.fetchLoading = false;
  700. this.hasmore = false;
  701. this.loading = false;
  702. return;
  703. }
  704. this.list = Array.isArray(list)
  705. ? [...this.list, ...list]
  706. : [...this.list];
  707. if (this.list.length < this.totalCount) {
  708. this.hasmore = true;
  709. this.tablePage++;
  710. } else {
  711. this.hasmore = false;
  712. }
  713. // this.list.push(this.list[0]);
  714. // this.list.push(this.list[0]);
  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. }
  725. this.fetchLoading = false;
  726. this.loading = false;
  727. });
  728. }, delay);
  729. },
  730. headerCellStyle(ci, col) {
  731. const base = this.cellBaseStyle(ci, col);
  732. base.height = this.cellHeight;
  733. base.fontSize = this.headerFontSize;
  734. base.position = "sticky";
  735. base.zIndex = 2;
  736. base.top = "0rpx";
  737. base.background = "#eaf2ff";
  738. // base.display = 'flex';
  739. // base.alignItems = 'center';
  740. // base.justifyContent = 'center';
  741. if (ci === 0) {
  742. base.zIndex = 3;
  743. }
  744. if (col.fixed) {
  745. base.left = this.stickyLeft(ci);
  746. }
  747. return base;
  748. },
  749. bodyCellStyle(ci, col) {
  750. const base = this.cellBaseStyle(ci, col);
  751. // base.lineHeight = this.cellHeight;
  752. base.padding = "12rpx";
  753. base.fontSize = this.bodyFontSize;
  754. if (this.bodyFontColor) {
  755. base.color = this.bodyFontColor;
  756. }
  757. if (col.fixed) {
  758. base.position = "sticky";
  759. base.left = this.stickyLeft(ci);
  760. base.zIndex = 2;
  761. }
  762. return base;
  763. },
  764. cellBaseStyle(ci, col) {
  765. const style = {};
  766. // style.height = this.cellHeight;
  767. if (col && col.width) {
  768. style.width = col.width;
  769. style.flex = `0 0 ${col.width}`;
  770. } else {
  771. style.flex = 1;
  772. }
  773. return style;
  774. },
  775. stickyLeft(ci) {
  776. const parts = [];
  777. for (let i = 0; i < ci; i++) {
  778. const c = this.columns[i];
  779. if (c && c.fixed && c.width) parts.push(c.width);
  780. }
  781. if (!parts.length) return "0rpx";
  782. if (parts.length === 1) return parts[0];
  783. return `calc(${parts.join(" + ")})`;
  784. },
  785. isPlainTitle(t) {
  786. return typeof t === "string" ? t.indexOf("<") === -1 : true;
  787. },
  788. titleNodes(t) {
  789. if (typeof t !== "string") return t;
  790. let html = String(t);
  791. html = html
  792. .replace(/<\s*view/g, "<div")
  793. .replace(/<\/\s*view\s*>/g, "</div>");
  794. html = html.replace(
  795. /:style=\"\{\s*textAlign:\s*'center'\s*\}\"/g,
  796. 'style="text-align:center;"',
  797. );
  798. return html;
  799. },
  800. handleClick(data, col) {
  801. if (
  802. this.tableType === "variety" ||
  803. this.tableType === "customerDetail" ||
  804. col.key !== "regionName"
  805. )
  806. return;
  807. uni.navigateTo({
  808. url:
  809. "/traceCodePackages/traceabilityReport/pages/customerScanningRate/detail/index?regionCode=" +
  810. data.regionCode +
  811. "&regionName=" +
  812. encodeURIComponent(data.regionName) +
  813. "&drugEntBaseInfoId=" +
  814. (data.druGentBaseInfoId || "") +
  815. "&physicName=" +
  816. encodeURIComponent(data.name || "") +
  817. "&scanType=" +
  818. this.scanType +
  819. (this.params.type ? "&type=" + this.params.type : ""),
  820. });
  821. },
  822. },
  823. };
  824. </script>
  825. <style scoped>
  826. .section {
  827. margin-top: 24rpx;
  828. transform: translate3d(0, 0, 0);
  829. }
  830. .section-header {
  831. position: relative;
  832. display: flex;
  833. align-items: center;
  834. justify-content: space-between;
  835. padding: 8rpx 8rpx;
  836. }
  837. .section-title {
  838. position: relative;
  839. font-size: 30rpx;
  840. font-weight: bold;
  841. color: #2c69ff;
  842. }
  843. .section-title::after {
  844. content: "";
  845. position: absolute;
  846. left: -20rpx;
  847. bottom: 13rpx;
  848. width: 8rpx;
  849. height: 50%;
  850. background: #2c69ff;
  851. border-radius: 10px;
  852. }
  853. .selector-wrap {
  854. position: relative;
  855. margin-right: 40rpx;
  856. }
  857. .selector {
  858. position: relative;
  859. display: flex;
  860. align-items: center;
  861. color: #2c69ff;
  862. padding-right: 30rpx;
  863. }
  864. .selector-text {
  865. font-size: 30rpx;
  866. max-width: 180rpx;
  867. overflow: hidden;
  868. white-space: nowrap;
  869. text-overflow: ellipsis;
  870. display: inline-block;
  871. }
  872. .selector-arrow {
  873. position: absolute;
  874. right: 0rpx;
  875. bottom: 14rpx;
  876. font-size: 30rpx;
  877. display: inline-block;
  878. width: 15rpx;
  879. height: 15rpx;
  880. border: 5rpx solid #2c69ff;
  881. border-top: none;
  882. border-left: none;
  883. transform-origin: 50% 50%;
  884. transform: rotate(45deg);
  885. transition: transform 0.2s;
  886. }
  887. .selector-arrow.open {
  888. bottom: 7rpx;
  889. transform: rotate(225deg);
  890. }
  891. .dropdown {
  892. position: absolute;
  893. right: 0rpx;
  894. top: 54rpx;
  895. width: 310rpx;
  896. max-height: 380rpx;
  897. background: #fff;
  898. border: 1rpx solid #eef0f4;
  899. border-radius: 12rpx;
  900. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
  901. z-index: 93;
  902. overflow: hidden;
  903. }
  904. .dropdown-search-bar {
  905. padding: 10rpx;
  906. border-bottom: 1rpx solid #f0f2f5;
  907. background: #fff;
  908. z-index: 94;
  909. }
  910. .dropdown-search-input {
  911. width: 100%;
  912. height: 60rpx;
  913. background: #f5f7fa;
  914. border-radius: 8rpx;
  915. padding: 0 20rpx;
  916. font-size: 28rpx;
  917. box-sizing: border-box;
  918. }
  919. .dropdown-scroll-view {
  920. flex: 1;
  921. width: 100%;
  922. max-height: 260rpx;
  923. /* Adjusted height to fit search bar */
  924. overflow-y: auto;
  925. }
  926. .dropdown-item {
  927. padding: 16rpx 24rpx;
  928. font-size: 28rpx;
  929. color: #333;
  930. text-wrap: wrap;
  931. }
  932. .dropdown-item + .dropdown-item {
  933. border-top: 1rpx solid #f0f2f5;
  934. }
  935. .table-scroll-x {
  936. position: relative;
  937. margin-top: 12rpx;
  938. width: 100%;
  939. min-height: 120rpx;
  940. border-radius: 16rpx;
  941. overflow: visible;
  942. }
  943. .card {
  944. background: #fff;
  945. font-size: 32rpx;
  946. }
  947. .table-header {
  948. display: flex;
  949. background: #eaf2ff;
  950. font-weight: bold;
  951. color: #2c69ff;
  952. border-top-left-radius: 16rpx;
  953. border-top-right-radius: 16rpx;
  954. }
  955. /* .table-body {
  956. margin-top: 8rpx;
  957. } */
  958. .row {
  959. display: flex;
  960. align-items: stretch;
  961. border-bottom: 1rpx solid #eef0f4;
  962. }
  963. .row:last-child,
  964. .row:nth-last-child(2) {
  965. border-bottom: none;
  966. }
  967. .loading-row {
  968. justify-content: flex-start;
  969. }
  970. .loading-wrapper {
  971. width: calc(100vw - 60rpx);
  972. height: 76rpx;
  973. display: flex;
  974. align-items: center;
  975. justify-content: center;
  976. position: sticky;
  977. top: 50%;
  978. left: 0;
  979. }
  980. .loading-icon {
  981. width: 40rpx;
  982. height: 40rpx;
  983. animation: spin 1s linear infinite;
  984. }
  985. @keyframes spin {
  986. from {
  987. transform: rotate(0deg);
  988. }
  989. to {
  990. transform: rotate(360deg);
  991. }
  992. }
  993. .cell {
  994. flex: 1;
  995. box-sizing: border-box;
  996. width: 0;
  997. box-sizing: border-box;
  998. display: flex;
  999. align-items: center;
  1000. justify-content: center;
  1001. /* text-align: center; */
  1002. word-break: break-all;
  1003. }
  1004. .table-body .cell {
  1005. background-color: #fff;
  1006. text-align: center;
  1007. }
  1008. .table-body .striped {
  1009. background: #f7f7f7;
  1010. }
  1011. .underline {
  1012. text-decoration: underline;
  1013. color: #2c69ff;
  1014. }
  1015. /* hide scrollbars for H5/App while preserving scroll behavior */
  1016. .no-scrollbar {
  1017. position: relative;
  1018. -ms-overflow-style: none;
  1019. scrollbar-width: none;
  1020. z-index: 2;
  1021. }
  1022. ::v-deep .no-scrollbar::-webkit-scrollbar {
  1023. display: none !important;
  1024. width: 0 !important;
  1025. height: 0 !important;
  1026. -webkit-appearance: none;
  1027. background: transparent;
  1028. }
  1029. .header-tooltip-wrap {
  1030. position: absolute;
  1031. top: 60rpx;
  1032. right: 0rpx;
  1033. z-index: 93;
  1034. }
  1035. .header-tooltip {
  1036. background: #000;
  1037. color: #fff;
  1038. border-radius: 8rpx;
  1039. padding: 8rpx 12rpx;
  1040. font-size: 24rpx;
  1041. width: 270rpx;
  1042. }
  1043. .header-tooltip-arrow {
  1044. position: absolute;
  1045. top: -11rpx;
  1046. right: 20rpx;
  1047. width: 0;
  1048. height: 0;
  1049. border-left: 10rpx solid transparent;
  1050. border-right: 10rpx solid transparent;
  1051. border-bottom: 12rpx solid #000;
  1052. margin: 0 auto;
  1053. }
  1054. .no-data-placeholder {
  1055. opacity: 0;
  1056. }
  1057. .no-data {
  1058. position: absolute;
  1059. top: 76rpx;
  1060. left: 0;
  1061. width: 100%;
  1062. z-index: 1;
  1063. }
  1064. </style>