From b4816f6294646157b50bb49f1d19eaf306e0ac8c Mon Sep 17 00:00:00 2001 From: he wei <858544502@qq.com> Date: 星期日, 13 十一月 2022 22:06:22 +0800 Subject: [PATCH] UA 0.1.4发布 --- src/components/menuList.vue | 506 ++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 363 insertions(+), 143 deletions(-) diff --git a/src/components/menuList.vue b/src/components/menuList.vue index 915c9f2..da328a1 100644 --- a/src/components/menuList.vue +++ b/src/components/menuList.vue @@ -34,6 +34,7 @@ width="800px" > <file-info + v-if="fileInfoVisible" :info="fileData" @ok="editOk" @cancel="editCancel" @@ -105,7 +106,7 @@ <el-checkbox-group v-model="winConfigForm.type"> <el-checkbox label="Vol" name="type">鐢靛帇(V)</el-checkbox> <el-checkbox label="Res" name="type">鍐呴樆(m惟)</el-checkbox> - <el-checkbox label="Cap" name="type">瀹归噺(Ah)</el-checkbox> + <!-- <el-checkbox label="Cap" name="type">瀹归噺(Ah)</el-checkbox> --> <el-checkbox label="Chain" name="type">杩炴帴鏉�(渭惟)</el-checkbox> <el-checkbox label="Cond" name="type">鐢靛(S)</el-checkbox> <el-checkbox label="Table" name="type">琛ㄦ牸</el-checkbox> @@ -128,77 +129,132 @@ :close-on-press-escape="false" width="600px" > - <table class="table"> - <thead> - <tr> - <th>绯绘暟鍚嶇О</th> - <th>绯绘暟鍊�</th> - <th>璇勪环</th> - </tr> - </thead> - <tbody> - <tr> - <td>浣庡帇绯绘暟K1</td> - <td> - <el-input - size="mini" - type="number" - v-model="params.volLowCoeK1" - placeholder="璇疯緭鍏ヤ綆鍘嬬郴鏁癒1" - ></el-input> - </td> - <td class="alarm"></td> - </tr> - <tr> - <td>楂樺帇绯绘暟K2</td> - <td> - <el-input - size="mini" - type="number" - v-model="params.volHighCoeK2" - placeholder="璇疯緭鍏ラ珮鍘嬬郴鏁癒2" - ></el-input> - </td> - <td class="warn"></td> - </tr> - <tr> - <td>鍐呴樆鍛婅K3</td> - <td> - <el-input - size="mini" - type="number" - v-model="params.resGoodCoeK3" - placeholder="璇疯緭鍏ュ唴闃诲憡璀3" - ></el-input> - </td> - <td class="warn"></td> - </tr> - <tr> - <td>鍐呴樆鏇存崲K4</td> - <td> - <el-input - size="mini" - type="number" - v-model="params.resBadCoeK4" - placeholder="璇疯緭鍏ュ唴闃绘洿鎹4" - ></el-input> - </td> - <td class="alarm"></td> - </tr> - <tr> - <td>杩炴帴鏉5</td> - <td> - <el-input - size="mini" - type="number" - v-model="params.chainResCoeK5" - placeholder="璇疯緭鍏ヨ繛鎺ユ潯K5" - ></el-input> - </td> - <td class="alarm"></td> - </tr> - </tbody> - </table> + <el-form + v-if="paramsVisible" + :model="p_params" + label-position="left" + size="mini" + :show-message="false" + ref="paramsForm" + :rules="rules" + > + <table class="table"> + <thead> + <tr> + <th>绯绘暟鍚嶇О</th> + <th>绯绘暟鍊�</th> + <th>璇勪环</th> + </tr> + </thead> + <tbody> + <tr> + <td>浣庡帇鍛婅(2V)</td> + <td> + <el-form-item prop="vol2LowCoeK1"> + <el-input + type="number" + v-model="p_params.vol2LowCoeK1" + placeholder="璇疯緭鍏ヤ綆鍘嬪憡璀�" + > + <template slot="append">V</template> + </el-input> + </el-form-item> + </td> + <td class="alarm"></td> + </tr> + <tr> + <td>楂樺帇鍛婅(2V)</td> + <td> + <el-form-item prop="vol2HighCoeK2"> + <el-input + type="number" + v-model="p_params.vol2HighCoeK2" + placeholder="璇疯緭鍏ラ珮鍘嬪憡璀�" + > + <template slot="append">V</template> + </el-input> + </el-form-item> + </td> + <td class="warn"></td> + </tr> + <tr> + <td>浣庡帇鍛婅(12V)</td> + <td> + <el-form-item prop="vol12LowCoeK1"> + <el-input + type="number" + v-model="p_params.vol12LowCoeK1" + placeholder="璇疯緭鍏ヤ綆鍘嬪憡璀�" + > + <template slot="append">V</template> + </el-input> + </el-form-item> + </td> + <td class="alarm"></td> + </tr> + <tr> + <td>楂樺帇鍛婅(12V)</td> + <td> + <el-form-item prop="vol12HighCoeK2"> + <el-input + type="number" + v-model="p_params.vol12HighCoeK2" + placeholder="璇疯緭鍏ラ珮鍘嬪憡璀�" + > + <template slot="append">V</template> + </el-input> + </el-form-item> + </td> + <td class="warn"></td> + </tr> + <tr> + <td>鍐呴樆鍛婅</td> + <td> + <el-form-item prop="resGoodCoeK3"> + <el-input + type="number" + v-model="p_params.resGoodCoeK3" + placeholder="璇疯緭鍏ュ唴闃诲憡璀�" + > + <template slot="append">%</template> + </el-input> + </el-form-item> + </td> + <td class="warn"></td> + </tr> + <tr> + <td>鍐呴樆鏇存崲</td> + <td> + <el-form-item prop="resBadCoeK4"> + <el-input + type="number" + v-model="p_params.resBadCoeK4" + placeholder="璇疯緭鍏ュ唴闃绘洿鎹�" + > + <template slot="append">%</template> + </el-input> + </el-form-item> + </td> + <td class="alarm"></td> + </tr> + <tr> + <td>杩炴帴鏉″憡璀�</td> + <td> + <el-form-item prop="chainResCoeK5"> + <el-input + type="number" + v-model="p_params.chainResCoeK5" + placeholder="璇疯緭鍏ヨ繛鎺ユ潯鍛婅" + > + <template slot="append">%</template> + </el-input> + </el-form-item> + </td> + <td class="alarm"></td> + </tr> + </tbody> + </table> + </el-form> <div class="footer"> <el-button @click="paramsCancel">鍙栨秷</el-button> <el-button type="primary" @click="paramsOk">纭畾</el-button> @@ -221,7 +277,9 @@ v-for="item in fileList" :key="item.fileId" :label="item.stationName + ' ' + item.fileName" - :value="item.fileUrl + '&&&&&' + item.fileId" + :value=" + item.fileUrl + '&&&&&' + item.fileId + '&&&&&' + item.fileName + " ></el-option> </el-select> </el-form-item> @@ -264,8 +322,19 @@ <script> import FileInfo from "@/components/fileInfo"; -import { getXmlValue, getFileList, getParams, setParams } from "@/apis"; -import { mapMutations } from "vuex"; +import { + getXmlValue, + getParamByFileId, + getFileList, + getParams, + setParams, + updateFileParam, +} from "@/apis"; +import { mapGetters, mapMutations } from "vuex"; +import CONST from "@/assets/js/const"; +import testVal from "@/assets/js/testVal"; + +const O_rules = CONST.rules; export default { name: "MenuList", @@ -284,10 +353,10 @@ title: "鍏抽棴鏂囦欢", method: "closeFile", }, - { - title: "鍏抽棴鎵�鏈夋枃浠�", - method: "closeAllFiles", - }, + // { + // title: "鍏抽棴鎵�鏈夋枃浠�", + // method: "closeAllFiles", + // }, ], }, { @@ -305,6 +374,11 @@ { title: "鍒嗙骇璇勪环", method: "viewsParams", + }, + { + title: "鏌ョ湅灞炴��", + method: "viewProp", + disabled: true, }, { title: "鐢熸垚鎶ュ憡", @@ -331,12 +405,16 @@ ], }, { - title: "help", + title: "甯姪", visible: false, children: [ { - title: "璇存槑涔�", + title: "浠〃璇存槑涔�", method: "instructionBook", + }, + { + title: "杞欢璇存槑涔�", + method: "softwareBook", }, { title: "鎿嶄綔瑙嗛", @@ -350,21 +428,81 @@ title: "鑱旂郴鏀寔", method: "contact", }, - // { - // title: "鍏跺畠", - // }, + { + title: "鍏充簬绂忓厜", + method: "others", + }, ], }, ]; - const params = { - chainResCoeK5: 1.2, + const p_params = { + chainResCoeK5: 120, enabled: 1, - resBadCoeK4: 1.6, - resGoodCoeK3: 1.25, - volHighCoeK2: 1.2, - volLowCoeK1: 0.8, + resBadCoeK4: 160, + resGoodCoeK3: 125, + vol2HighCoeK2: 2.35, + vol2LowCoeK1: 1.8, + vol12HighCoeK2: 14.1, + vol12LowCoeK1: 10.8, + }; + const R_resGoodCoeK3 = { + validator(rule, value, callback) { + testVal(rule, value, callback, O_rules.resGoodCoeK3); + }, + trigger: ["change", "blur"], + }; + const rules = { + vol2LowCoeK1: [ + { required: true, message: "璇疯緭鍏ヤ綆鍘嬮槇鍊�", trigger: "blur" }, + { + validator(rule, value, callback) { + testVal(rule, value, callback, O_rules.vol2LowCoeK1); + }, + trigger: ["change", "blur"], + }, + ], + vol2HighCoeK2: [ + { required: true, message: "璇疯緭鍏ラ珮鍘嬮槇鍊�", trigger: "blur" }, + { + validator(rule, value, callback) { + testVal(rule, value, callback, O_rules.vol2HighCoeK2); + }, + trigger: ["change", "blur"], + }, + ], + vol12LowCoeK1: [ + { required: true, message: "璇疯緭鍏ヤ綆鍘嬮槇鍊�", trigger: "blur" }, + { + validator(rule, value, callback) { + testVal(rule, value, callback, O_rules.vol12LowCoeK1); + }, + trigger: ["change", "blur"], + }, + ], + vol12HighCoeK2: [ + { required: true, message: "璇疯緭鍏ラ珮鍘嬮槇鍊�", trigger: "blur" }, + { + validator(rule, value, callback) { + testVal(rule, value, callback, O_rules.vol12HighCoeK2); + }, + trigger: ["change", "blur"], + }, + ], + resGoodCoeK3: [ + { required: true, message: "璇疯緭鍏ュ唴闃诲憡璀︾郴鏁�", trigger: "blur" }, + R_resGoodCoeK3, + ], + resBadCoeK4: [ + { required: true, message: "璇疯緭鍏ュ唴闃绘洿鎹㈢郴鏁�", trigger: "blur" }, + R_resGoodCoeK3, + ], + chainResCoeK5: [ + { required: true, message: "璇疯緭鍏ヨ繛鎺ユ潯鍛婅绯绘暟", trigger: "blur" }, + R_resGoodCoeK3, + ], }; return { + rules, askInstallVisible: false, pkgVersion: "", pkgPath: "", @@ -372,7 +510,7 @@ processVisible: false, fileParseVisible: false, fileUrl: "", - params, + p_params, paramsVisible: false, winConfigVisible: false, winConfigForm: { @@ -406,14 +544,33 @@ fileList2() { return this.fileList.filter((v) => v.fileId != this.compareForm.id1); }, + ...mapGetters("setting", [ + "volVisiable", + "resVisiable", + "capVisiable", + "chainVisiable", + "condVisiable", + "tableVisiable", + "params", + ]), + // p_params() { + // return JSON.parse(JSON.stringify(this.params)); + // } }, watch: { $route(n) { // console.log(n, n.name, !["compare", "result"].includes(n.name)); - this.menuList[1].children[3].disabled = !["compare", "result"].includes( + this.menuList[1].children[4].disabled = !["compare", "result"].includes( + n.name + ); + this.menuList[1].children[3].disabled = !["result"].includes(n.name); + this.menuList[0].children[1].disabled = !["compare", "result"].includes( n.name ); }, + params(n) { + this.p_params = Object.assign({}, n); + } }, methods: { ...mapMutations("setting", [ @@ -462,15 +619,15 @@ }, initEvents() { window.api.receive("selected-file", (path, data) => { + // console.log(path, data, 'selected-file') if (data && data == "MenuList") { - // console.log(path.filePaths, "MenuList"); - this.parseFile(path.filePaths[0]); + this.parseTmpFile(path.filePaths[0]); } }); window.api.receive("messageupdate", (data) => { // console.log(data, "====update?"); - if(data.status == -1) { + if (data.status == -1) { this.$message.error(data.msg); } else { this.$message.info(data.msg); @@ -492,7 +649,16 @@ this.pkgPath = downloadedFile; this.askInstallVisible = true; }); + + // this.$bus.$on("checkCloseAll", this.checkCloseAll); + + this.$bus.$on("setAlarmValue", this.viewsParams); + this.$bus.$on("windowConfirm", this.windowConfig); + // this.$bus.$on('viewProp', this.viewProp); }, + // checkCloseAll(bl) { + // this.menuList[0].children[2].disabled = !bl; + // }, install() { this.askInstallVisible = false; window.api.send("quitAndInstall"); @@ -506,23 +672,31 @@ } this.percent = Math.round(progressObj.percent * 100) / 100; }, - parseFile(url, notTmp, cbfn) { - notTmp = notTmp || false; - let _url = url, - fileId; - if (notTmp) { - [_url, fileId] = url.split("&&&&&"); - } + parseTmpFile(url) { const params = { - filePath: _url, + filePath: url, }; getXmlValue(params).then((res) => { const { code, data, data2 } = res.data; if (code && data) { - // console.log(data2, 'xxxxx'); this.fileData = data2.fileParam; - this.currFile.name = !notTmp ? data2.fileNameTmp : data2.fileName; + this.currFile.name = data2.fileNameTmp; this.currFile.url = data2.fileUrl; + this.currFile.fileId = undefined; + this.fileInfoVisible = true; + } else { + this.$message.error("鏂囦欢瑙f瀽澶辫触"); + } + }); + }, + parseFile(url, cbfn) { + let [_url, fileId, fileName] = url.split("&&&&&"); + getParamByFileId(fileId).then((res) => { + const { code, data, data2 } = res.data; + if (code && data) { + this.fileData = data2; + this.currFile.name = fileName; + this.currFile.url = _url; this.currFile.fileId = fileId; this.fileInfoVisible = true; if (cbfn && "function" == typeof cbfn) { @@ -535,19 +709,33 @@ }, editOk(data) { this.fileInfoVisible = false; + // 娌℃湁fileId 涓嶄慨鏀瑰弬鏁� + if (!this.currFile.fileId) { + this.toRes(data); + return false; + } + updateFileParam(this.currFile.fileId, data).then((res) => { + const { code, data } = res.data; + if (code && data) { + this.$message.success("淇敼鎴愬姛"); + } else { + this.$message.error("淇敼澶辫触"); + } + }); this.toRes(); }, editCancel(data) { this.fileInfoVisible = false; this.toRes(); }, - toRes() { + toRes(params) { const { name, url, fileId } = this.currFile; this.$router.push({ path: "/result/" + name, query: { url, fileId, + params, }, }); this.$bus.$emit("checkScroll"); @@ -562,10 +750,12 @@ id2: undefined, type: [], }; - this.compareVisible = true; + this.getFileList().then(() => { + this.compareVisible = true; + }); }, getFileList() { - getFileList().then((res) => { + return getFileList().then((res) => { let { code, data, data2 } = res.data; let list = []; if (code && data) { @@ -618,12 +808,17 @@ this[method](type.some((val) => val == v)); }); this.winConfigVisible = false; + this.$bus.$emit("windowConfigChanged"); }, goData() { this.$router.push("/data"); }, instructionBook() { this.$router.push("/book"); + }, + softwareBook() { + // TODO + this.$router.push("/softwareBook"); }, video() { this.$router.push("/qrcode"); @@ -633,6 +828,9 @@ }, exportReport() { this.$bus.$emit("export"); + }, + viewProp() { + this.$bus.$emit("viewProp"); }, // 鍒嗙骇璇勪环 璁剧疆鍙傛暟 viewsParams() { @@ -646,46 +844,52 @@ // } // this.$bus.$emit("export"); this.paramsVisible = true; + this.$nextTick(() => { + this.$refs.paramsForm.resetFields(); + }); }, paramsCancel() { this.paramsVisible = false; }, paramsOk() { - // TODO - // 鍙傛暟瑕佹煡鐪� - const { - chainResCoeK5, - resBadCoeK4, - resGoodCoeK3, - volHighCoeK2, - volLowCoeK1, - } = this.params; - if ( - !volLowCoeK1 || - volLowCoeK1 != volLowCoeK1 * 1 || - !volHighCoeK2 || - volHighCoeK2 != volHighCoeK2 * 1 || - !resGoodCoeK3 || - resGoodCoeK3 != resGoodCoeK3 * 1 || - !resBadCoeK4 || - resBadCoeK4 != resBadCoeK4 * 1 || - !chainResCoeK5 || - chainResCoeK5 != chainResCoeK5 * 1 - ) { - this.$message.error("绯绘暟涓嶈兘涓虹┖ 搴斾负澶т簬0鐨勬暟鍊�"); - return false; - } - // console.log(this.params); - // 鏇存柊鍒嗙骇鍙傛暟 - setParams(this.params).then((res) => { - const { code, data } = res.data; - if (code) { - this.$message.success("鏇存柊鎴愬姛"); + this.$refs.paramsForm.validate((valid, info) => { + // 鏍¢獙閫氳繃 + if (valid) { + // 鏇存柊鍒嗙骇鍙傛暟 + setParams(this.p_params).then((res) => { + const { code, data } = res.data; + if (code) { + this.setParams(this.p_params); + this.$message.success("鏇存柊鎴愬姛"); + this.paramsVisible = false; + this.$bus.$emit("paramsUpdated"); + } else { + this.$message.error("鎿嶄綔澶辫触"); + } + }); } else { - this.$message.error("鎿嶄綔澶辫触"); + const field = { + vol2LowCoeK1: "浣庡帇闃堝��", + vol2HighCoeK2: "楂樺帇闃堝��", + vol12LowCoeK1: "浣庡帇闃堝��", + vol12HighCoeK2: "楂樺帇闃堝��", + resGoodCoeK3: "鍐呴樆鍛婅绯绘暟", + resBadCoeK4: "鍐呴樆鏇存崲绯绘暟", + chainResCoeK5: "杩炴帴鏉″憡璀︾郴鏁�", + }; + let errStr = ""; + Object.keys(info).forEach((val) => { + info[val].forEach((v) => { + errStr += field[val] + ": " + v.message + "; "; + }); + }); + this.$message.error({ + message: "瀛樺湪鏍¢獙鏈�氳繃鐨勬暟鎹紒" + errStr, + duration: 5000, + }); + return false; } }); - this.paramsVisible = false; }, fileParseOk() { if (!this.fileUrl) { @@ -693,19 +897,21 @@ return false; } // console.log(this.fileUrl); - this.parseFile(this.fileUrl, true, () => { + this.parseFile(this.fileUrl, () => { this.fileParseVisible = false; }); }, parseOneFile() { this.fileUrl = ""; - this.fileParseVisible = true; + this.getFileList().then(() => { + this.fileParseVisible = true; + }); }, getParams() { getParams().then((res) => { let { code, data } = res.data; if (code) { - this.params = data; + // this.p_params = data; this.setParams(data); } }); @@ -713,12 +919,23 @@ checkForUpdate() { window.api.send("check-update"); }, + others() { + this.$router.push("/others"); + }, }, mounted() { this.getParams(); this.initEvents(); this.getFileList(); + this.winConfigForm.type = [ + "Res", + "Vol", + "Cap", + "Cond", + "Chain", + "Table", + ].filter((v) => this[v.toLowerCase() + "Visiable"]); }, }; </script> @@ -827,6 +1044,9 @@ .footer { text-align: right; } + :deep(.el-form-item) { + margin-bottom: 0; + } } .table { width: 100%; -- Gitblit v1.9.1