From 7cc7aac8bd386f5d6f33239557c1878a83d7346a Mon Sep 17 00:00:00 2001 From: qx <1084500556@qq.com> Date: 星期四, 03 四月 2025 15:31:57 +0800 Subject: [PATCH] qx --- src/views/index.vue | 6 ++- src/utils/rem.js | 24 ++++++++++++ src/main.js | 2 package.json | 2 + src/mixins/responsive-inline.js | 34 +++++++++++++++++ src/views/reservation/resercopy/index.vue | 4 ++ src/views/sampling/sampling/index.vue | 6 ++ postcss.config.js | 19 +++++++++ 8 files changed, 93 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 800eace..80766c9 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,8 @@ "moment": "^2.29.4", "nprogress": "0.2.0", "pinyin-match": "^1.2.2", + "postcss-px-to-viewport": "^1.1.1", + "postcss-pxtorem": "^5.1.1", "print-js": "^1.6.0", "quill": "1.3.7", "screenfull": "5.0.2", diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..de6c183 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,19 @@ +module.exports = { + plugins: { + // 'postcss-pxtorem': { + // rootValue: 19, // 琛ㄧず鏍瑰厓绱犲瓧浣撳ぇ灏忔垨鏍规嵁input鍙傛暟杩斿洖鏍瑰厓绱犲瓧浣撳ぇ灏� + // propList: ['*'], // 鍙互浠巔x鏇存敼涓簉em鐨勫睘鎬�, 閫氶厤绗�*琛ㄧず鍚敤鎵�鏈夊睘鎬� + // selectorBlackList: ['.norem'] // 杩囨护鎺�.norem寮�澶寸殑class锛屼笉杩涜rem杞崲 + // }, + 'postcss-px-to-viewport': { + viewportWidth: 1920, // 璁捐绋垮搴︼紙濡�750px鐨刄I绋匡級 + unitPrecision: 3, // 杞崲鍚庡崟浣嶇殑灏忔暟浣嶆暟 + viewportUnit: 'vw', // 鐩爣鍗曚綅锛堟帹鑽恦w锛� + selectorBlackList: ['.ignore', 'vant'], // 涓嶈浆鎹㈢殑绫诲悕锛堝绗笁鏂圭粍浠跺簱锛� + minPixelValue: 1, // 灏忎簬绛変簬1px鐨勫�间笉杞崲 + mediaQuery: false, // 濯掍綋鏌ヨ涓殑px涓嶈浆鎹� + exclude: /node_modules/ // 鎺掗櫎node_modules鐩綍 + } + } +} + diff --git a/src/main.js b/src/main.js index d603c74..42f906b 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,7 @@ import Print from "vue-print-nb"; import JsonExcel from "vue-json-excel"; - +import '@/utils/rem.js'; //鍦╩ain.js涓紩鍏em.js Vue.component("downloadExcel", JsonExcel); import "./assets/icons"; // icon diff --git a/src/mixins/responsive-inline.js b/src/mixins/responsive-inline.js new file mode 100644 index 0000000..456a1c5 --- /dev/null +++ b/src/mixins/responsive-inline.js @@ -0,0 +1,34 @@ +import { debounce } from 'lodash'; +export default { + methods: { + getResponsiveStyles() { + const width = window.innerWidth; + if (width < 576) { + return 'font-size: 14px !important; padding: 8px !important;'; + } else if (width < 768) { + return 'font-size: 16px !important; padding: 12px !important;'; + } else { + return 'font-size: 18px !important; padding: 16px !important;'; + } + } + }, + mounted() { + this.makeInlineStylesResponsive(); + window.addEventListener('resize', debounce(this.makeInlineStylesResponsive, 200)); + }, + beforeDestroy() { + window.removeEventListener('resize', this.makeInlineStylesResponsive); + }, + methods: { + makeInlineStylesResponsive() { + const elements = this.$el.querySelectorAll('[style]'); + elements.forEach(el => { + const originalStyle = el.getAttribute('style'); + el.setAttribute('style', ` + ${originalStyle}; + ${this.getResponsiveStyles()} + `); + }); + } + } +} \ No newline at end of file diff --git a/src/utils/rem.js b/src/utils/rem.js new file mode 100644 index 0000000..d44199b --- /dev/null +++ b/src/utils/rem.js @@ -0,0 +1,24 @@ +// 閰嶇疆鍩烘湰澶у皬 +let baseSize = 19; + +// 璁剧疆 rem 鍑芥暟 +function setRem () { + //褰撳墠椤甸潰瀹藉害鐩稿浜�1920px灞忓箷瀹界殑缂╂斁姣斾緥锛屽彲鏍规嵁鑷繁闇�瑕佷慨鏀广�� + let scale = document.documentElement.clientWidth / 1920; + console.log(scale,2222) + //璁剧疆椤甸潰鏍硅妭鐐瑰瓧浣撳ぇ灏忥紙鈥淢ath.min(scale, 2)鈥� 鎸囨渶楂樻斁澶ф瘮渚嬩负2锛屽彲鏍规嵁瀹為檯涓氬姟闇�姹傝皟鏁达級 + document.documentElement.style.fontSize = baseSize * Math.min(scale, 2) + 'px' +} +setRem(); //鍒濆鍖� + +// 閫傞厤 - 閲嶇疆鍑芥暟 +function resetRem (num) { + if(num) baseSize = Number(num); + setRem(); +} +window.resetRem = resetRem; // 鍏ㄥ眬鍙皟鐢�(鍏朵粬鏂瑰紡涔熷彲) + +// 鏀瑰彉绐楀彛澶у皬鏃堕噸缃� rem +window.onresize = function () { + setRem() +}; \ No newline at end of file diff --git a/src/views/index.vue b/src/views/index.vue index 8d43c82..d925659 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -41,7 +41,7 @@ <h4>杩戜竴鏈堢粺璁�</h4> </div> <div class="data-view"> - <div id="main" style="width:95%;height:330px"></div> + <div id="main"></div> </div> <div class="view"> <div id="main2"></div> @@ -414,7 +414,7 @@ .day { height: 40px; line-height: 40px; - font-size: 12px; + font-size: 14px; } .data-view { @@ -424,6 +424,8 @@ #main { padding: 10px; + width:95%; + height:330px } .view { diff --git a/src/views/reservation/resercopy/index.vue b/src/views/reservation/resercopy/index.vue index 5a19f42..fed9291 100644 --- a/src/views/reservation/resercopy/index.vue +++ b/src/views/reservation/resercopy/index.vue @@ -209,6 +209,7 @@ <el-upload ref="upload" :limit="1" + :key="uploadKey" accept=".xlsx, .xls" :headers="upload.headers" :data="data" @@ -637,6 +638,7 @@ ], }, ListObj: {}, + uploadKey:0, // 閬僵灞� loading: true, pacStatus: "鍚敤", @@ -873,6 +875,8 @@ /** 瀵煎叆鎸夐挳鎿嶄綔 */ handleImport() { if (this.objs.drugManufacturerId && this.objs.reservationTime) { + this.$refs.upload?.clearFiles(); + this.uploadKey = Date.now(); // 鏀瑰彉 key 寮哄埗閲嶆柊娓叉煋缁勪欢 this.upload.title = "鐢ㄦ埛瀵煎叆"; this.upload.open = true; } else { diff --git a/src/views/sampling/sampling/index.vue b/src/views/sampling/sampling/index.vue index 1b4d333..88fd823 100644 --- a/src/views/sampling/sampling/index.vue +++ b/src/views/sampling/sampling/index.vue @@ -105,7 +105,7 @@ </div> <div style="width: 50%"> <!-- v-if="this.rightTabShow" --> - <el-table v-if="tableList.length > 0" v-loading="loading" :data="tableList" @selection-change="handleChange" + <el-table :row-key="getRowKey" v-if="tableList.length > 0" v-loading="loading" :data="tableList" @selection-change="handleChange" :span-method="objectSpanMethod" ref="tab1" :row-class-name="tableRowClassName" border height="520px"> <el-table-column type="selection" width="40" align="center" /> <!-- :selectable="selectEnable" --> @@ -662,6 +662,10 @@ console.log(`鏄惁绂佺敤閫夋嫨: ${this.disableSelections}`); }, + getRowKey(row) { + return row.id; // 蹇呴』鍞竴涓旂ǔ瀹� + }, + fetchData(tjNumber) { return new Promise((resolve, reject) => { this.loading = true; -- Gitblit v1.8.0