ScanRateTable.vue 26 KB

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