ScanRateTable.vue 26 KB

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