NPList.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  1. <template>
  2. <div class="container1">
  3. <div class="databox">
  4. <el-scrollbar :style="{ height: Height + 'px' }">
  5. <div class="box">
  6. <div class="title">
  7. <!-- <div style="display: flex; align-items: center">-->
  8. <!-- <div class="bg"></div>-->
  9. <!-- 样本数据录入-->
  10. <!-- </div>-->
  11. <div class="header" v-show="!addStatus && !editStatus">
  12. <Search
  13. :searchOptions="searchForm"
  14. ref="searchRef"
  15. @data-list="getTableData"
  16. @reset-list="reset"
  17. />
  18. </div>
  19. <div class="btns">
  20. <el-upload
  21. style="float: left"
  22. :action="uploadUrl"
  23. :on-success="handleSuccess"
  24. :before-upload="beforeUpload"
  25. :limit="1"
  26. accept=".xlsx, .xls"
  27. :show-file-list="false"
  28. ref="uploadRef"
  29. >
  30. <el-button size="small" type="primary">文件上传</el-button>
  31. </el-upload>
  32. <el-button
  33. style="margin-left: 15px"
  34. type="primary"
  35. size="small"
  36. class="btn"
  37. @click="
  38. downloadSPCTemplate(
  39. '/api/v1/spc/downloadTemplate',
  40. '/spc/template/NP控制图数据导入模版.xlsx'
  41. )
  42. "
  43. >模版下载</el-button
  44. >
  45. </div>
  46. </div>
  47. <div class="info" v-if="!addStatus">
  48. <el-table
  49. :data="tableData"
  50. border
  51. :style="{
  52. height: maxHeight - 150 + 'px',
  53. width: maxWidth + 'px',
  54. }"
  55. :show-overflow-tooltip="true"
  56. >
  57. <el-table-column
  58. align="center"
  59. prop="created"
  60. sortable
  61. label="日期"
  62. >
  63. <template #default="{ row }"
  64. ><span>{{ formatDate(row.created) }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column align="center" prop="fileName" label="文件名称">
  68. <template #default="{ row }"
  69. ><a
  70. class="blue-underline"
  71. :href="downloadUrl + row.filePath"
  72. >{{ row.fileName }}</a
  73. >
  74. </template>
  75. </el-table-column>
  76. <el-table-column align="center" width="160" prop="" label="操作">
  77. <template #default="{ row }">
  78. <el-button
  79. type="primary"
  80. size="small"
  81. class="btn"
  82. @click="compute(row.filePath)"
  83. style="height: 25px"
  84. >计算</el-button
  85. >
  86. <el-button
  87. type="info"
  88. size="small"
  89. class="btn"
  90. style="height: 25px"
  91. @click="deleteSubmit(row.id)"
  92. >删除</el-button
  93. >
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <Pagination
  98. :total="currentOption.total"
  99. :page="currentOption.page"
  100. :limit="currentOption.limit"
  101. :pageSizes="currentOption.pageSizes"
  102. v-model:page="currentOption.page"
  103. v-model:limit="currentOption.limit"
  104. @pagination="getTableData"
  105. />
  106. </div>
  107. </div>
  108. </el-scrollbar>
  109. </div>
  110. </div>
  111. </template>
  112. <script setup>
  113. import { ref } from "vue";
  114. import * as echarts from "echarts";
  115. import { useDictionaryStore } from "@/store";
  116. import {
  117. getQualityFileList,
  118. getData,
  119. addDatas,
  120. deleteQualityFile,
  121. updateData,
  122. getTaskCode,
  123. NPCompute2,
  124. } from "@/api/analysis";
  125. import Search from "@/components/Search/index.vue";
  126. import { uploadFileApi } from "@/api/file";
  127. import { useCrud } from "@/hooks/userCrud";
  128. const { Utils } = useCrud({
  129. src: "/api/v1/spc/pDownloadTemplate",
  130. });
  131. const { downloadSPCTemplate } = Utils;
  132. // 定义 props
  133. const props = defineProps({
  134. chart: {
  135. type: String, // 类型为字符串
  136. required: true, // 必传
  137. },
  138. });
  139. const formatDate = (dateString) => {
  140. const date = new Date(dateString);
  141. const year = date.getFullYear();
  142. const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份从0开始,所以需要+1
  143. const day = String(date.getDate()).padStart(2, "0");
  144. return `${year}-${month}-${day}`;
  145. };
  146. const year = ref("0");
  147. const currentOption = reactive({
  148. total: 0,
  149. page: 1,
  150. limit: 10,
  151. pageSizes: [10, 20, 30, 40, 50],
  152. });
  153. const lableValue = ref("");
  154. const searchRef = ref(null);
  155. const getTaskOption = async () => {
  156. const { data } = await getTaskCode({
  157. operationCode: JSON.parse(value.value).value,
  158. });
  159. taskOption.value = data;
  160. };
  161. const getTableData = async () => {
  162. const { data, code, msg } = await getQualityFileList({
  163. ...searchRef.value.searchForm,
  164. pageNo: currentOption.page,
  165. pageSize: currentOption.limit,
  166. // yearStr: year.value,
  167. chart: props.chart,
  168. });
  169. if (code == "200") {
  170. tableData.value = data.records;
  171. showData.value = { ...data.records, list: null };
  172. // if (tableData.value.length > 0) {
  173. // setChart1();
  174. // setChart2();
  175. // }
  176. currentOption.total = data.totalCount;
  177. currentOption.page = data.pageNo;
  178. oldDataJSON.value = JSON.stringify(data.records);
  179. }
  180. disabled.value = false;
  181. };
  182. const searchForm = [
  183. {
  184. label: "日期",
  185. prop: "createds",
  186. type: "daterange",
  187. },
  188. {
  189. label: "文件名称",
  190. prop: "model",
  191. type: "input",
  192. },
  193. ];
  194. //编辑状态
  195. const editStatus = ref(false);
  196. const addStatus = ref(false);
  197. const changeEditstatus = () => {
  198. editStatus.value = !changeEditstatus.value;
  199. addStatus.value = false;
  200. };
  201. const changeaddstatus = () => {
  202. addStatus.value = !addStatus.value;
  203. editStatus.value = false;
  204. };
  205. const canceleOp = () => {
  206. addStatus.value = false;
  207. editStatus.value = false;
  208. reset();
  209. };
  210. const Y1value = ref([]);
  211. const X1array = ref([]);
  212. const setY1value = () => {
  213. Y1value.value = [];
  214. tableData.value.forEach((item) => {
  215. Y1value.value.push(item.avg);
  216. });
  217. Y1value.value.unshift("");
  218. Y1value.value.push("");
  219. chartsOption1.value.series[0].data = Y1value.value;
  220. };
  221. const setX1array = async () => {
  222. X1array.value = await [];
  223. tableData.value.forEach((item, index) => {
  224. X1array.value.push(index + 1);
  225. });
  226. X1array.value.unshift("");
  227. X1array.value.push("");
  228. chartsOption1.value.xAxis[0].data = X1array.value;
  229. };
  230. const { dicts } = useDictionaryStore();
  231. const importStatus = ref(false);
  232. const disabled = ref(false);
  233. const tableData = ref([]);
  234. //Form
  235. const ruleFormRef = ref(null);
  236. const addItem = {
  237. // abnormal: "",
  238. accuracy1: 0,
  239. accuracy2: 0,
  240. accuracy3: 0,
  241. accuracy4: 0,
  242. accuracy5: 0,
  243. analyseUser: "",
  244. avg: 0,
  245. batchNo: "",
  246. checkDeviceNo: "",
  247. checkUser: "",
  248. dateStr: "",
  249. measure: "",
  250. model: "",
  251. range: 0,
  252. };
  253. const rules = {
  254. qualityTaskId: [
  255. {
  256. required: true,
  257. trigger: "change",
  258. },
  259. ],
  260. dateStr: [
  261. {
  262. required: true,
  263. trigger: "change",
  264. },
  265. ],
  266. model: [
  267. {
  268. required: true,
  269. trigger: "change",
  270. },
  271. ],
  272. batchNo: [
  273. {
  274. required: true,
  275. trigger: "change",
  276. },
  277. ],
  278. accuracy1: [
  279. {
  280. required: true,
  281. trigger: "change",
  282. },
  283. ],
  284. accuracy2: [
  285. {
  286. required: true,
  287. trigger: "change",
  288. },
  289. ],
  290. accuracy3: [
  291. {
  292. required: true,
  293. trigger: "change",
  294. },
  295. ],
  296. accuracy4: [
  297. {
  298. required: true,
  299. trigger: "change",
  300. },
  301. ],
  302. accuracy5: [
  303. {
  304. required: true,
  305. trigger: "change",
  306. },
  307. ],
  308. checkUser: [
  309. {
  310. required: true,
  311. trigger: "change",
  312. },
  313. ],
  314. checkDeviceNo: [
  315. {
  316. required: true,
  317. trigger: "change",
  318. },
  319. ],
  320. // abnormal: [
  321. // {
  322. // required: true,
  323. // trigger: "change",
  324. // },
  325. // ],
  326. analyseUser: [
  327. {
  328. required: true,
  329. trigger: "change",
  330. },
  331. ],
  332. measure: [
  333. {
  334. required: false,
  335. trigger: "change",
  336. },
  337. ],
  338. };
  339. const resItem = {
  340. // abnormal: "",
  341. analyseUser: "",
  342. batchNo: "",
  343. checkDeviceNo: "",
  344. checkUser: "",
  345. dateStr: "",
  346. measure: "",
  347. model: "",
  348. };
  349. const addData = ref({
  350. // abnormal: "",
  351. analyseUser: "",
  352. batchNo: "",
  353. checkDeviceNo: "",
  354. checkUser: "",
  355. dateStr: "",
  356. measure: "",
  357. model: "",
  358. });
  359. const accuracysSum = ref(0);
  360. const taskChange = (value) => {
  361. taskOption.value.forEach((item) => {
  362. if (item.id == value) {
  363. addData.value.model = item.prodtModel;
  364. accuracysSum.value = Number(item.processCount);
  365. addData.value.accuracys = [];
  366. let array = [];
  367. for (let i = 0; i < accuracysSum.value; i++) {
  368. array.push(0);
  369. }
  370. addData.value.accuracys = array;
  371. }
  372. });
  373. };
  374. const oldDataJSON = ref("");
  375. const showData = ref({});
  376. const url = ref(import.meta.env.VITE_APP_BASE_API + "/api/v1/spc/import");
  377. const headers = { Authorization: `${localStorage.getItem("token")}` };
  378. const opOptions = ref([...dicts.spc_operation]);
  379. const sccOptions = ref([...dicts.spc_control_chart]);
  380. const setChart1Info = () => {
  381. // chartsOption1.value.title[0].text = `上限=${showData.value.avgMax ? showData.value.avgMax : "-"}`;
  382. // chartsOption1.value.title[0].text = `x̄=${showData.value.avgAvg ? showData.value.avgAvg : "-"}`;
  383. chartsOption1.value.series[0].markLine.data[0].yAxis = JSON.parse(
  384. value.value
  385. ).avgMax;
  386. chartsOption1.value.series[0].markLine.data[0].label.formatter = ` 上限=${
  387. JSON.parse(value.value).avgMax ? JSON.parse(value.value).avgMax : "0"
  388. }`;
  389. chartsOption1.value.series[0].markLine.data[1].yAxis = JSON.parse(value.value)
  390. .avgMin
  391. ? JSON.parse(value.value).avgMin
  392. : 0;
  393. chartsOption1.value.series[0].markLine.data[1].label.formatter = ` 下限=${JSON.parse(value.value).avgMin ? JSON.parse(value.value).avgMin : "0"}`;
  394. chartsOption1.value.series[0].markLine.data[2].yAxis = JSON.parse(
  395. value.value
  396. ).avgMid;
  397. chartsOption1.value.series[0].markLine.data[2].label.formatter = `x̄=${
  398. JSON.parse(value.value).avgMid
  399. }`;
  400. // chartsOption1.value.title[2].text = `下限=${showData.value.avgMin ? showData.value.avgMin : "0"}`;
  401. };
  402. const setChart2Info = () => {
  403. // chartsOption2.value.title[0].text = `上限=${showData.value.rangeMax ? showData.value.rangeMax : "-"}`;
  404. // chartsOption2.value.title[0].text = `R=${showData.value.rangeAvg ? showData.value.rangeAvg : "-"}`;
  405. chartsOption2.value.series[0].markLine.data[0].yAxis = JSON.parse(
  406. value.value
  407. ).rangeMax;
  408. chartsOption2.value.series[0].markLine.data[0].label.formatter = ` 上限=${
  409. JSON.parse(value.value).rangeMax ? JSON.parse(value.value).rangeMax : "0"
  410. }`;
  411. chartsOption2.value.series[0].markLine.data[1].yAxis = JSON.parse(value.value)
  412. .rangeMin
  413. ? JSON.parse(value.value).rangeMin
  414. : 0;
  415. chartsOption2.value.series[0].markLine.data[1].label.formatter = ` 下限=${
  416. JSON.parse(value.value).rangeMin ? JSON.parse(value.value).rangeMin : "0"
  417. }`;
  418. chartsOption2.value.series[0].markLine.data[2].yAxis = JSON.parse(
  419. value.value
  420. ).rangeMid;
  421. chartsOption2.value.series[0].markLine.data[2].label.formatter = `x̄=${
  422. JSON.parse(value.value).rangeMid
  423. }`;
  424. // chartsOption2.value.title[2].text = `下限=${showData.value.rangeMin ? showData.value.rangeMin : "0"}`;
  425. };
  426. const setChart1 = () => {
  427. setChart1Info();
  428. setY1value();
  429. setX1array();
  430. charts1.value.setOption(chartsOption1.value, true);
  431. };
  432. const setChart2 = () => {
  433. setChart2Info();
  434. setY2value();
  435. setX2array();
  436. charts2.value.setOption(chartsOption2.value, true);
  437. };
  438. //修改
  439. const updataItem = (row) => {
  440. editStatus.value = true;
  441. addData.value = row;
  442. addStatus.value = true;
  443. };
  444. //导入按钮
  445. const onSuccess = (res) => {
  446. const { code, msg, data } = res;
  447. if (code != "200") {
  448. ElMessage.error(msg);
  449. } else {
  450. tableData.value = data.list;
  451. showData.value = { ...data, list: null };
  452. setChart1();
  453. setChart2();
  454. oldDataJSON.value = JSON.stringify(data.list);
  455. importStatus.value = true;
  456. ElMessage.success(msg);
  457. }
  458. };
  459. const taskOption = ref([]);
  460. const value = ref(opOptions.value[0].remark);
  461. const title = ref("调阻精度");
  462. var value2 = ref("");
  463. const showLable = ref("调阻");
  464. const changeSelect = () => {
  465. setTimeout(async () => {
  466. getTaskOption();
  467. showLable.value = selectRef.value.currentPlaceholder;
  468. opOptions.value.forEach((item) => {
  469. if (item.dictLabel == showLable.value) {
  470. lableValue.value = item.dictValue;
  471. }
  472. });
  473. switch (showLable.value) {
  474. case "调阻":
  475. title.value = "调阻精度";
  476. break;
  477. case "粘片":
  478. title.value = "剪切强度";
  479. break;
  480. case "键合":
  481. title.value = "键合强度";
  482. break;
  483. default:
  484. title.value = "调阻精度";
  485. break;
  486. }
  487. await getTableData();
  488. chartsOption1.value.title[0].text = `${title.value}的Xbar-R控制图`;
  489. // tableData.value.forEach((item) => {
  490. // item.accuracy1 = 0;
  491. // item.accuracy2 = 0;
  492. // item.accuracy3 = 0;
  493. // item.accuracy4 = 0;
  494. // item.accuracy5 = 0;
  495. // item.avg = 0;
  496. // item.range = 0;
  497. // });
  498. // setChart1();
  499. // changeSelect2();
  500. }, 0);
  501. };
  502. // const searchData = computed(() =>
  503. // tableData.value.filter((item) => item.data.includes(searchValue.value))
  504. // );
  505. const selectRef = ref(null);
  506. //保存
  507. const changeEdit = async () => {
  508. if (disabled.value == false) {
  509. disabled.value = true;
  510. } else {
  511. const { data, code, msg } = await getHandleData([...tableData.value]);
  512. if (code == "200") {
  513. ElMessage.success(msg);
  514. tableData.value = data.list;
  515. showData.value = { ...data, list: null };
  516. setChart1();
  517. setChart2();
  518. oldDataJSON.value = JSON.stringify(data.list);
  519. }
  520. disabled.value = false;
  521. }
  522. };
  523. const cancelEdit = () => {
  524. tableData.value = JSON.parse(oldDataJSON.value);
  525. disabled.value = false;
  526. };
  527. const maxHeight = ref(null);
  528. const maxWidth = ref(null);
  529. const charts1 = shallowRef(null);
  530. const charts2 = shallowRef(null);
  531. const chartsOption1 = ref({
  532. title: [
  533. // {
  534. // text: `x̄=${showData.value.avgAvg ? showData.value.avgAvg : "-"}`,
  535. // right: "5%",
  536. // top: "42%",
  537. // textStyle: {
  538. // fontSize: 15,
  539. // color: "#333",
  540. // fontWeight: 100,
  541. // },
  542. // },
  543. {
  544. text: `${title.value}的Xbar-R控制图`,
  545. left: "40%",
  546. },
  547. {
  548. text: "样",
  549. left: "4%",
  550. top: "28%",
  551. },
  552. {
  553. text: "本",
  554. left: "4%",
  555. top: "35%",
  556. },
  557. {
  558. text: "均",
  559. left: "4%",
  560. top: "42%",
  561. },
  562. {
  563. text: "值",
  564. left: "4%",
  565. top: "49%",
  566. },
  567. ],
  568. grid: {
  569. right: "15%",
  570. },
  571. toolbox: {
  572. feature: {
  573. saveAsImage: {},
  574. },
  575. },
  576. tooltip: {
  577. show: true,
  578. },
  579. xAxis: [
  580. {
  581. type: "category",
  582. boundaryGap: false,
  583. data: [],
  584. },
  585. ],
  586. yAxis: [
  587. {
  588. type: "value",
  589. },
  590. ],
  591. series: [
  592. {
  593. type: "line",
  594. lineStyle: {
  595. color: "rgb(26, 122, 240)",
  596. },
  597. symbolSize: 13,
  598. symbol: "circle",
  599. itemStyle: {
  600. color: (params) => {
  601. const avg = JSON.parse(value.value);
  602. const paramValue = Number(params.value);
  603. if (
  604. paramValue <= Number(avg.avgMax) &&
  605. paramValue >= Number(avg.avgMin)
  606. ) {
  607. return "rgb(26, 122, 240)";
  608. } else {
  609. return "red";
  610. }
  611. },
  612. },
  613. markLine: {
  614. silent: true,
  615. data: [
  616. {
  617. silent: false,
  618. yAxis: 0,
  619. label: {
  620. position: "end",
  621. formatter: `上限=${JSON.parse(value.value).avgMax ? JSON.parse(value.value).avgMax : "-"}`,
  622. color: "#333",
  623. },
  624. lineStyle: { type: "solid", color: "#333", width: 2 },
  625. },
  626. {
  627. silent: false,
  628. yAxis: 0,
  629. label: {
  630. position: "end",
  631. formatter: `下限=${JSON.parse(value.value).avgMin ? JSON.parse(value.value).avgMin : "-"}`,
  632. color: "#333",
  633. },
  634. lineStyle: {
  635. type: "solid",
  636. color: "#333",
  637. width: 2,
  638. },
  639. },
  640. {
  641. yAxis: 0,
  642. silent: false,
  643. label: {
  644. position: "end",
  645. formatter: ``,
  646. color: "#333",
  647. },
  648. lineStyle: {
  649. type: "solid",
  650. color: "#333",
  651. width: 2,
  652. },
  653. },
  654. ],
  655. },
  656. },
  657. ],
  658. });
  659. const chartsOption2 = ref({
  660. title: [
  661. // {
  662. // text: `R=${showData.value.rangeAvg ? showData.value.rangeAvg : "-"}`,
  663. // right: "5%",
  664. // top: "42%",
  665. // textStyle: {
  666. // fontSize: 15,
  667. // color: "#333",
  668. // fontWeight: 100,
  669. // },
  670. // },
  671. {
  672. text: "样",
  673. left: "4%",
  674. top: "28%",
  675. },
  676. {
  677. text: "本",
  678. left: "4%",
  679. top: "35%",
  680. },
  681. {
  682. text: "极",
  683. left: "4%",
  684. top: "42%",
  685. },
  686. {
  687. text: "值",
  688. left: "4%",
  689. top: "49%",
  690. },
  691. ],
  692. toolbox: {
  693. feature: {
  694. saveAsImage: {},
  695. },
  696. },
  697. grid: {
  698. right: "15%",
  699. },
  700. xAxis: [
  701. {
  702. type: "category",
  703. boundaryGap: false,
  704. data: [],
  705. },
  706. ],
  707. yAxis: [
  708. {
  709. type: "value",
  710. },
  711. ],
  712. tooltip: {
  713. show: true,
  714. },
  715. series: [
  716. {
  717. type: "line",
  718. lineStyle: {
  719. color: "rgb(26, 122, 240)",
  720. },
  721. symbolSize: 13,
  722. symbol: "circle",
  723. itemStyle: {
  724. color: (params) => {
  725. const range = JSON.parse(value.value);
  726. const paramValue = Number(params.value);
  727. if (
  728. paramValue <= Number(range.rangeMax) &&
  729. paramValue >= Number(range.rangeMin)
  730. ) {
  731. return "rgb(26, 122, 240)";
  732. } else {
  733. return "red";
  734. }
  735. },
  736. },
  737. markLine: {
  738. silent: true,
  739. data: [
  740. {
  741. silent: false,
  742. yAxis: 0,
  743. label: {
  744. position: "end",
  745. formatter: `上限=${JSON.parse(value.value).rangeMax ? JSON.parse(value.value).rangeMax : "-"}`,
  746. color: "#333",
  747. },
  748. lineStyle: { type: "solid", color: "#333", width: 2 },
  749. },
  750. {
  751. silent: false,
  752. yAxis: 0,
  753. label: {
  754. position: "end",
  755. formatter: `下限=${JSON.parse(value.value).rangeMin ? JSON.parse(value.value).rangeMin : "-"}`,
  756. color: "#333",
  757. },
  758. lineStyle: { type: "solid", color: "#333", width: 2 },
  759. },
  760. {
  761. yAxis: 0,
  762. silent: false,
  763. label: {
  764. position: "end",
  765. formatter: ``,
  766. color: "#333",
  767. },
  768. lineStyle: {
  769. type: "solid",
  770. color: "#333",
  771. width: 2,
  772. },
  773. },
  774. ],
  775. },
  776. },
  777. ],
  778. });
  779. const Height = ref(0);
  780. const setHeight = () => {
  781. Height.value = document.querySelector(".databox").clientHeight;
  782. maxHeight.value = document.querySelector(".info").clientHeight;
  783. maxWidth.value = document.querySelector(".info").clientWidth;
  784. };
  785. const Y2value = ref([]);
  786. const X2array = ref([]);
  787. const setY2value = () => {
  788. Y2value.value = [];
  789. tableData.value.forEach((item) => {
  790. Y2value.value.push(item.range);
  791. });
  792. Y2value.value.unshift("");
  793. Y2value.value.push("");
  794. chartsOption2.value.series[0].data = Y2value.value;
  795. };
  796. const setX2array = () => {
  797. X2array.value = [];
  798. tableData.value.forEach((item, index) => {
  799. X2array.value.push(index + 1);
  800. });
  801. X2array.value.unshift("");
  802. X2array.value.push("");
  803. chartsOption2.value.xAxis[0].data = X2array.value;
  804. };
  805. //当新增或者编辑的确定操作
  806. const submit = () => {
  807. if (editStatus.value == true) {
  808. updateSubmit();
  809. } else {
  810. addSubmit();
  811. }
  812. };
  813. const addSubmit = async () => {
  814. await ruleFormRef.value.validate(async (valid, fields) => {
  815. if (valid) {
  816. const { data, code } = await addDatas({
  817. ...addData.value,
  818. yearStr: year.value,
  819. operation: lableValue.value,
  820. });
  821. if (code == "200") {
  822. ElMessage.success("添加成功!");
  823. reset();
  824. getTableData();
  825. }
  826. } else {
  827. ElMessage.error("请检查表单信息");
  828. }
  829. });
  830. };
  831. const deleteSubmit = async (id) => {
  832. const { data, code } = await deleteQualityFile({
  833. id,
  834. });
  835. if (code == "200") {
  836. ElMessage.success("删除成功!");
  837. getTableData();
  838. }
  839. };
  840. const emit = defineEmits(["tableData"]);
  841. const compute = async (filePath) => {
  842. const { data, code } = await NPCompute2({ filePath: filePath });
  843. if (code === "200") {
  844. emit("tableData", data);
  845. }
  846. };
  847. const updateSubmit = async () => {
  848. const { data, code } = await updateData({
  849. ...addData.value,
  850. });
  851. if (code == "200") {
  852. ElMessage.success("更新成功!");
  853. reset();
  854. getTableData();
  855. }
  856. };
  857. const reset = () => {
  858. addStatus.value = false;
  859. editStatus.value = false;
  860. addData.value = { ...resItem };
  861. searchRef.value.searchForm = {};
  862. currentOption.value = {
  863. total: 0,
  864. page: 0,
  865. limit: 12,
  866. pageSizes: [12],
  867. operation: value.value,
  868. };
  869. getTableData();
  870. };
  871. const setView = () => {
  872. setHeight();
  873. charts1.value = echarts.init(document.getElementById("charts"));
  874. charts2.value = echarts.init(document.getElementById("charts1"));
  875. charts1.value.setOption(chartsOption1.value, true);
  876. charts2.value.setOption(chartsOption2.value, true);
  877. };
  878. const downloadUrl =
  879. import.meta.env.VITE_APP_BASE_API + "/api/v1/spc/pDownloadExcel?filePath=";
  880. const uploadUrl = ref("");
  881. const beforeUpload = (file) => {
  882. const isExcel =
  883. file.type === "application/vnd.ms-excel" ||
  884. file.type ===
  885. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  886. if (!isExcel) {
  887. ElMessage.error("只能上传Excel文件!");
  888. }
  889. return isExcel;
  890. };
  891. const uploadRef = ref("uploadRef");
  892. const handleSuccess = (response) => {
  893. if (response.code === "200") {
  894. ElMessage.success("Excel导入成功!");
  895. uploadRef.value.clearFiles();
  896. getTableData();
  897. } else {
  898. ElMessage.error("Excel导入失败!");
  899. }
  900. };
  901. onMounted(async () => {
  902. getTaskOption();
  903. setHeight();
  904. year.value = new Date().getFullYear() + "";
  905. opOptions.value.forEach((item) => {
  906. if (item.dictLabel == showLable.value) {
  907. lableValue.value = item.dictValue;
  908. }
  909. });
  910. await getTableData();
  911. uploadUrl.value =
  912. import.meta.env.VITE_APP_BASE_API +
  913. "/api/v1/spc/pUploadExcel?chart=" +
  914. props.chart;
  915. // value2.value = "Xbar-R";
  916. // xbarRRefMethod();
  917. // nextTick(() => {
  918. // charts1.value = echarts.init(document.getElementById("charts"));
  919. // charts2.value = echarts.init(document.getElementById("charts1"));
  920. // charts1.value.setOption(chartsOption1.value, true);
  921. // charts2.value.setOption(chartsOption2.value, true);
  922. // });
  923. // window.addEventListener("resize", setView);
  924. });
  925. onBeforeUnmount(() => {
  926. // window.removeEventListener("resize", setView);
  927. });
  928. </script>
  929. <style lang="scss" scoped>
  930. @media print {
  931. #print {
  932. margin-left: -18%;
  933. }
  934. }
  935. .blue-underline {
  936. text-decoration: none;
  937. color: #008cff;
  938. }
  939. .blue-underline:hover {
  940. text-decoration: underline;
  941. color: blue;
  942. }
  943. .ellipsis-text {
  944. white-space: nowrap; /* 禁止换行 */
  945. overflow: hidden; /* 隐藏超出部分 */
  946. text-overflow: ellipsis; /* 显示省略号 */
  947. width: 100%; /* 宽度占满单元格 */
  948. }
  949. .formStyle {
  950. width: 400px;
  951. margin: 20px auto;
  952. }
  953. .container1 {
  954. width: 100%;
  955. height: 100%;
  956. display: flex;
  957. background-color: white;
  958. .infobox {
  959. width: 200px;
  960. .header {
  961. height: 120px;
  962. border-bottom: 2px solid #00000010;
  963. padding: 20px;
  964. }
  965. .body {
  966. padding: 20px;
  967. }
  968. }
  969. .databox {
  970. flex: 1;
  971. border-left: 2px solid #00000010;
  972. .box {
  973. height: 710px;
  974. padding: 5px 20px;
  975. display: flex;
  976. flex-direction: column;
  977. .illustrate {
  978. padding: 20px 60px;
  979. }
  980. .tableTitle {
  981. text-align: center;
  982. margin: 10px 0;
  983. padding-right: 40px;
  984. }
  985. .header {
  986. margin-top: 20px;
  987. //margin-left: 100px;
  988. display: flex;
  989. width: 100%;
  990. height: auto;
  991. }
  992. //.title {
  993. // height: 50px;
  994. // display: flex;
  995. // align-items: center;
  996. // margin-bottom: 10px;
  997. // justify-content: space-between;
  998. // .btns {
  999. // display: flex;
  1000. // align-items: center;
  1001. // .btn {
  1002. // height: 24px;
  1003. // font-size: 14px;
  1004. // margin: 0 5px;
  1005. // }
  1006. // }
  1007. //}
  1008. .info {
  1009. margin-top: 20px;
  1010. flex: 1;
  1011. height: 300px;
  1012. }
  1013. }
  1014. }
  1015. }
  1016. </style>