indexJinShan.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <div class="qualityControl">
  3. <div v-if="!readonly && shiFouGuoShen" class="btn">
  4. <el-button icon="ibps-icon-edit" @click="onCopy">复制</el-button>
  5. <el-button type="success" icon="ibps-icon-plus" @click="onAddClick"
  6. >添加</el-button
  7. >
  8. <el-button type="danger" icon="ibps-icon-close" @click="onRemoveClick"
  9. >删除</el-button
  10. >
  11. <el-button icon="ibps-icon-import" @click="onImportClick">导入</el-button>
  12. <el-button icon="ibps-icon-export" @click="onExportClick">导出</el-button>
  13. </div>
  14. <div class="table">
  15. <el-table
  16. :data="showPaperList"
  17. border
  18. @selection-change="handleSelectionChange"
  19. >
  20. <el-table-column type="selection" />
  21. <el-table-column label="序号" width="50">
  22. <template slot-scope="{ row, $index }">
  23. {{ (currentPage - 1) * pageSize + $index + 1 }}</template
  24. >
  25. </el-table-column>
  26. <el-table-column label="选择项目" prop="xuanZeXiangMu" width="200">
  27. <template slot-scope="{ row }">
  28. <ibps-custom-dialog
  29. v-model="row.xuanZeXiangMu"
  30. template-key="snzkyfxzjbgxzjyxm"
  31. placeholder="请选择"
  32. store="id"
  33. icon="ibps-icon-search-plus"
  34. type="dialog"
  35. :disabled="readonly"
  36. />
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="项目" prop="xiangMu" width="160">
  40. <template slot-scope="{ row }">
  41. <div v-if="isReadonly">{{ row.xiangMu }}</div>
  42. <el-input
  43. v-else
  44. type="textarea"
  45. autosize
  46. v-model="row.xiangMu"
  47. ></el-input>
  48. </template>
  49. </el-table-column>
  50. <!-- <el-table-column label="设备名称" prop="sheBeiMingCheng" width="160">
  51. <template slot-scope="{ row }">
  52. <div v-if="isReadonly">{{ row.sheBeiMingCheng }}</div>
  53. <el-input v-else v-model="row.sheBeiMingCheng"></el-input
  54. ></template>
  55. </el-table-column> -->
  56. <el-table-column label="质控品厂家" prop="zhiKongChangJia" width="160">
  57. <template slot-scope="{ row }">
  58. <div v-if="isReadonly">{{ row.zhiKongChangJia }}</div>
  59. <el-input v-else v-model="row.zhiKongChangJia"></el-input
  60. ></template>
  61. </el-table-column>
  62. <el-table-column label="质控批号" prop="zhiKongPinPiHao" width="100">
  63. <template slot-scope="{ row }">
  64. <div v-if="isReadonly">{{ row.zhiKongPinPiHao }}</div>
  65. <el-input v-else v-model="row.zhiKongPinPiHao"></el-input
  66. ></template>
  67. </el-table-column>
  68. <el-table-column
  69. label="批号开始时间"
  70. prop="piHaoKaiShiShiJia"
  71. width="100"
  72. >
  73. <template slot-scope="{ row }">
  74. <div v-if="isReadonly">{{ row.piHaoKaiShiShiJia }}</div>
  75. <el-input v-else v-model="row.piHaoKaiShiShiJia"></el-input>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="失控规则" prop="shiKongGuiZe" width="100">
  79. <template slot-scope="{ row }">
  80. <div v-if="isReadonly">{{ row.shiKongGuiZe }}</div>
  81. <el-input v-else v-model="row.shiKongGuiZe"></el-input>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="单位" prop="zhiKongTuDanWei">
  85. <template slot-scope="{ row }">
  86. <div v-if="isReadonly">{{ row.zhiKongTuDanWei }}</div>
  87. <el-input v-else v-model="row.zhiKongTuDanWei"></el-input>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="设定质控图数据">
  91. <el-table-column label="水平" prop="zhiKongTuShuiPing">
  92. <template slot-scope="{ row }">
  93. <div v-if="isReadonly">{{ row.zhiKongTuShuiPing }}</div>
  94. <el-input v-else v-model="row.zhiKongTuShuiPing"></el-input>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="均值" prop="zhiKongTuJunZhi">
  98. <template slot-scope="{ row }">
  99. <div v-if="isReadonly">{{ row.zhiKongTuJunZhi }}</div>
  100. <el-input v-else v-model="row.zhiKongTuJunZhi"></el-input>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="SD" prop="zhiKongTuSd">
  104. <template slot-scope="{ row }">
  105. <div v-if="isReadonly">{{ row.zhiKongTuSd }}</div>
  106. <el-input v-else v-model="row.zhiKongTuSd"></el-input>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="CV%" prop="zhiKongTuCv">
  110. <template slot-scope="{ row }">
  111. <div v-if="isReadonly">{{ row.zhiKongTuCv }}</div>
  112. <el-input v-else v-model="row.zhiKongTuCv"></el-input>
  113. </template>
  114. </el-table-column>
  115. </el-table-column>
  116. <el-table-column label="当月原始测定数据统计">
  117. <el-table-column label="均值" prop="yuanShiJunZhi">
  118. <template slot-scope="{ row }">
  119. <div v-if="isReadonly">{{ row.yuanShiJunZhi }}</div>
  120. <el-input v-else v-model="row.yuanShiJunZhi"></el-input>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="SD" prop="yuanShiSd">
  124. <template slot-scope="{ row }">
  125. <div v-if="isReadonly">{{ row.yuanShiSd }}</div>
  126. <el-input v-else v-model="row.yuanShiSd"></el-input>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="CV%" prop="yuanShiCv">
  130. <template slot-scope="{ row }">
  131. <div v-if="isReadonly">{{ row.yuanShiCv }}</div>
  132. <el-input v-else v-model="row.yuanShiCv"></el-input>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="测定数" prop="yuanShiN">
  136. <template slot-scope="{ row }">
  137. <div v-if="isReadonly">{{ row.yuanShiN }}</div>
  138. <el-input v-else v-model="row.yuanShiN"></el-input>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="失控数" prop="shiKongShu">
  142. <template slot-scope="{ row }">
  143. <div v-if="isReadonly">{{ row.shiKongShu }}</div>
  144. <el-input v-else v-model="row.shiKongShu"></el-input>
  145. </template>
  146. </el-table-column>
  147. </el-table-column>
  148. <el-table-column label="当月在控数据统计">
  149. <el-table-column label="均值" prop="chuJunZhi">
  150. <template slot-scope="{ row }">
  151. <div v-if="isReadonly">{{ row.chuJunZhi }}</div>
  152. <el-input v-else v-model="row.chuJunZhi"></el-input>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="SD" prop="chuSd">
  156. <template slot-scope="{ row }">
  157. <div v-if="isReadonly">{{ row.chuSd }}</div>
  158. <el-input v-else v-model="row.chuSd"></el-input>
  159. </template>
  160. </el-table-column>
  161. <el-table-column label="CV%" prop="chuCv">
  162. <template slot-scope="{ row }">
  163. <div v-if="isReadonly">{{ row.chuCv }}</div>
  164. <el-input v-else v-model="row.chuCv"></el-input>
  165. </template>
  166. </el-table-column>
  167. </el-table-column>
  168. <el-table-column label="累积质控数据统计">
  169. <el-table-column label="均值" prop="leiJunZhi">
  170. <template slot-scope="{ row }">
  171. <div v-if="isReadonly">{{ row.leiJunZhi }}</div>
  172. <el-input v-else v-model="row.leiJunZhi"></el-input>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="SD" prop="leiSd">
  176. <template slot-scope="{ row }">
  177. <div v-if="isReadonly">{{ row.leiSd }}</div>
  178. <el-input v-else v-model="row.leiSd"></el-input>
  179. </template>
  180. </el-table-column>
  181. <el-table-column label="CV%" prop="leiCv">
  182. <template slot-scope="{ row }">
  183. <div v-if="isReadonly">{{ row.leiCv }}</div>
  184. <el-input v-else v-model="row.leiCv"></el-input>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="测定数" prop="leiN">
  188. <template slot-scope="{ row }">
  189. <div v-if="isReadonly">{{ row.leiN }}</div>
  190. <el-input v-else v-model="row.leiN"></el-input>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="在控率%" prop="zaiKongLv">
  194. <template slot-scope="{ row }">
  195. <div v-if="isReadonly">{{ row.zaiKongLv }}</div>
  196. <el-input v-else v-model="row.zaiKongLv"></el-input>
  197. </template>
  198. </el-table-column>
  199. </el-table-column>
  200. <el-table-column label="CV%控制范围">
  201. <el-table-column label="%" prop="cvKongZhiFanWei">
  202. <template slot-scope="{ row }">
  203. <div v-if="isReadonly">{{ row.cvKongZhiFanWei }}</div>
  204. <el-input v-else v-model="row.cvKongZhiFanWei"></el-input>
  205. </template>
  206. </el-table-column>
  207. </el-table-column>
  208. <el-table-column label="是否合格" prop="shiFouHeGe" width="120">
  209. <template slot-scope="{ row }">
  210. <div v-if="isReadonly">{{ row.shiFouHeGe }}</div>
  211. <el-select v-else v-model="row.shiFouHeGe">
  212. <el-option
  213. v-for="item in shiFouHeGeOptions"
  214. :key="item.value"
  215. :label="item.label"
  216. :value="item.value"
  217. >
  218. </el-option>
  219. </el-select>
  220. </template>
  221. </el-table-column>
  222. <el-table-column
  223. v-if="!readonly && shiFouGuoShen"
  224. label="操作栏位"
  225. fixed="right"
  226. >
  227. <template slot-scope="{ row, $index }">
  228. <el-button
  229. type="text"
  230. icon="ibps-icon-edit"
  231. @click="onEditClick(row, $index)"
  232. >编辑</el-button
  233. >
  234. </template>
  235. </el-table-column>
  236. </el-table>
  237. <el-pagination
  238. style="margin-top: 5px; padding-bottom: 10px"
  239. :current-page="currentPage"
  240. :page-sizes="[10, 15, 20, 30, 50, 100]"
  241. :page-size="pageSize"
  242. layout="total,sizes,prev,pager,next"
  243. :total="tableData.length"
  244. @size-change="handleSizeChange"
  245. @current-change="handleCurrentChange"
  246. />
  247. </div>
  248. <input
  249. id=""
  250. ref="file1"
  251. style="display: none"
  252. type="file"
  253. name=""
  254. accept=".xlsx,.xls"
  255. @change="handleUploadChange1"
  256. />
  257. </div>
  258. </template>
  259. <script>
  260. import IbpsCustomDialog from '@/business/platform/data/templaterender/custom-dialog'
  261. import { cloneDeep } from 'lodash'
  262. import xlsx from 'xlsx'
  263. import fs from 'file-saver'
  264. import dayjs from 'dayjs'
  265. export default {
  266. components: {
  267. 'ibps-custom-dialog': IbpsCustomDialog
  268. },
  269. props: {
  270. formData: {
  271. type: Object,
  272. default: () => {}
  273. },
  274. params: {
  275. type: Object,
  276. default: () => {}
  277. },
  278. readonly: {
  279. type: Boolean,
  280. default: false
  281. }
  282. },
  283. data() {
  284. return {
  285. tableData: [],
  286. multipleSelection: [],
  287. pageSize: 10,
  288. currentPage: 1,
  289. isReadonly:
  290. this.readOnly ||
  291. this.params.nodeId == 'Activity_1riq0sr' ||
  292. this.params.nodeId == 'Activity_0q5i1ex',
  293. columns: {
  294. xuanZeXiangMu: '选择项目',
  295. xiangMu: '项目',
  296. // sheBeiMingCheng: '设备名称',
  297. zhiKongPinPiHao: '质控批号',
  298. piHaoKaiShiShiJia: '批号开始时间',
  299. zhiKongChangJia: '质控品厂家',
  300. shiKongGuiZe: '失控规则',
  301. zhiKongTuDanWei: '单位',
  302. zhiKongTuShuiPing: '设定质控图数据水平',
  303. zhiKongTuJunZhi: '设定质控图数据均值',
  304. zhiKongTuSd: '设定质控图数据SD',
  305. zhiKongTuCv: '设定质控图数据CV%',
  306. yuanShiJunZhi: '当月原始测定数据统计均值',
  307. yuanShiSd: '当月原始测定数据统计SD',
  308. yuanShiCv: '当月原始测定数据统计CV%',
  309. yuanShiN: '当月原始测定数据统计测定数',
  310. shiKongShu: '当月原始测定数据统计失控数',
  311. chuJunZhi: '当月在控数据统计均值',
  312. chuSd: '当月在控数据统计SD',
  313. chuCv: '当月在控数据统计CV%',
  314. leiJunZhi: '累积质控数据统计均值',
  315. leiSd: '累积质控数据统计SD',
  316. leiCv: '累积质控数据统计CV%',
  317. leiN: '累积质控数据统计测定数',
  318. zaiKongLv: '累积质控数据统计在控率%',
  319. cvKongZhiFanWei: 'CV%控制范围',
  320. shiFouHeGe: '是否合格'
  321. },
  322. shiFouHeGeOptions: [
  323. {
  324. value: '合格',
  325. label: '合格'
  326. },
  327. {
  328. value: '不合格',
  329. label: '不合格'
  330. }
  331. ]
  332. }
  333. },
  334. computed: {
  335. // 分页结果
  336. showPaperList() {
  337. const start = (this.currentPage - 1) * this.pageSize
  338. const end = start + this.pageSize
  339. return this.tableData.slice(start, end)
  340. },
  341. shiFouGuoShen() {
  342. if (
  343. !this.formData.shiFouGuoShen ||
  344. this.formData.shiFouGuoShen === '已退回' ||
  345. this.formData.shiFouGuoShen === '已暂存' ||
  346. this.formData.shiFouGuoShen === '待编制'
  347. ) {
  348. return true
  349. }
  350. return false
  351. }
  352. },
  353. watch: {
  354. 'formData.dlxmsnzkyfxzb': {
  355. handler(val) {
  356. if (
  357. (val && val.length) ||
  358. (Array.prototype.isPrototypeOf(val) && val.length === 0)
  359. ) {
  360. // console.log(this.formData)
  361. this.tableData = val
  362. }
  363. },
  364. immediate: true
  365. },
  366. tableData: {
  367. handler(val) {
  368. this.$emit('change-data', 'dlxmsnzkyfxzb', val)
  369. },
  370. deep: true
  371. }
  372. },
  373. methods: {
  374. onCopy() {
  375. if (this.multipleSelection.length > 0) {
  376. this.tableData = this.tableData.concat(
  377. cloneDeep(this.multipleSelection)
  378. )
  379. } else {
  380. this.$message.warning('请选择数据')
  381. }
  382. },
  383. xlsx(json, fields, filename = '.xlsx') {
  384. // 导出xlsx
  385. json.forEach((item) => {
  386. for (const i in item) {
  387. if (fields.hasOwnProperty(i)) {
  388. item[fields[i]] = item[i]
  389. }
  390. delete item[i] // 删除原先的对象属性
  391. }
  392. })
  393. const sheetName = filename // excel的文件名称
  394. const wb = xlsx.utils.book_new() // 工作簿对象包含一SheetNames数组,以及一个表对象映射表名称到表对象。XLSX.utils.book_new实用函数创建一个新的工作簿对象。
  395. const ws = xlsx.utils.json_to_sheet(json, {
  396. header: Object.values(fields)
  397. }) // 将JS对象数组转换为工作表。
  398. wb.SheetNames.push(sheetName)
  399. wb.Sheets[sheetName] = ws
  400. const defaultCellStyle = {
  401. font: { name: 'Verdana', sz: 13, color: 'FF00FF88' },
  402. fill: { fgColor: { rgb: 'FFFFAA00' } }
  403. } // 设置表格的样式
  404. const wopts = {
  405. bookType: 'xlsx',
  406. bookSST: false,
  407. type: 'binary',
  408. cellStyles: true,
  409. defaultCellStyle: defaultCellStyle,
  410. showGridLines: false
  411. } // 写入的样式
  412. const wbout = xlsx.write(wb, wopts)
  413. const blob = new Blob([this.s2ab(wbout)], {
  414. type: 'application/octet-stream'
  415. })
  416. fs.saveAs(blob, filename + '.xlsx')
  417. },
  418. s2ab(s) {
  419. let buf
  420. if (typeof ArrayBuffer !== 'undefined') {
  421. buf = new ArrayBuffer(s.length)
  422. const view = new Uint8Array(buf)
  423. for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff
  424. return buf
  425. } else {
  426. buf = new Array(s.length)
  427. for (let i = 0; i !== s.length; ++i) buf[i] = s.charCodeAt(i) & 0xff
  428. return buf
  429. }
  430. },
  431. handleSelectionChange(val) {
  432. this.multipleSelection = val
  433. },
  434. onAddClick() {
  435. this.tableData.push({
  436. xuanZeXiangMu: '',
  437. oldXiangMu: '',
  438. xiangMu: '',
  439. // sheBeiMingCheng: '',
  440. zhiKongPinPiHao: '',
  441. piHaoKaiShiShiJia: '',
  442. zhiKongChangJia: '',
  443. shiKongGuiZe: '',
  444. zhiKongTuDanWei: '',
  445. zhiKongTuShuiPing: '',
  446. zhiKongTuJunZhi: '',
  447. zhiKongTuSd: '',
  448. zhiKongTuCv: '',
  449. yuanShiJunZhi: '',
  450. yuanShiSd: '',
  451. yuanShiCv: '',
  452. yuanShiN: '',
  453. shiKongShu: '',
  454. chuJunZhi: '',
  455. chuSd: '',
  456. chuCv: '',
  457. leiJunZhi: '',
  458. leiSd: '',
  459. leiCv: '',
  460. leiN: '',
  461. zaiKongLv: '',
  462. cvKongZhiFanWei: '',
  463. shiFouHeGe: ''
  464. })
  465. },
  466. onImportClick() {
  467. // const btn = document.querySelector('.dynamic-form-table .ibps-icon-import')
  468. // btn.click()
  469. this.$refs.file1.click()
  470. console.log('导入')
  471. },
  472. /* 读取文件 将文件转换为二进制 */
  473. readFile(file) {
  474. return new Promise((resolve) => {
  475. const reader = new FileReader()
  476. reader.readAsBinaryString(file)
  477. reader.onload = (ev) => {
  478. resolve(ev.target.result)
  479. }
  480. })
  481. },
  482. // 转换对象的key
  483. switchDeviceObj(data, originalObj) {
  484. const result = []
  485. data.forEach((item) => {
  486. const obj = {}
  487. for (const key in originalObj) {
  488. // 对日期格式的数据做兼容处理
  489. if (item[originalObj[key]] instanceof Date) {
  490. obj[key] =
  491. dayjs(item[originalObj[key]])
  492. .add(8, 'hour')
  493. .format('YYYY-MM-DD') || ''
  494. } else {
  495. obj[key] = String(item[originalObj[key]] || '')
  496. }
  497. }
  498. result.push(obj)
  499. })
  500. return result
  501. },
  502. async switchXmToId(list) {
  503. // const sql = `select id_, jian_yan_xiang_mu from t_nlfwb`
  504. const { variables: { data = {} } = {} } = await this.$common.request(
  505. 'query',
  506. {
  507. key: 'getNlfwbProject',
  508. params: [null]
  509. }
  510. )
  511. for (let i = 0; i < list.length; i++) {
  512. const row = list[i]
  513. const t = data.find(
  514. (item) => item.jian_yan_xiang_mu.trim() === row.xiangMu.trim()
  515. )
  516. row.xuanZeXiangMu = t?.id_ || ''
  517. }
  518. },
  519. checkDate(data) {
  520. // 校验日期字段是否符合要求
  521. const dateRegex = /^(\d{4})[-/](0[1-9]|1[0-2])[-/](0[1-9]|[12]\d|3[01])$/
  522. for (let i = 0; i < data.length; i++) {
  523. const row = data[i]
  524. if (row.piHaoKaiShiShiJia && !dateRegex.test(row.piHaoKaiShiShiJia)) {
  525. throw new Error(`第${i + 1}行时间格式错误!`)
  526. }
  527. }
  528. },
  529. async handleUploadChange1(file) {
  530. try {
  531. const dataBinary = await this.readFile(file.target.files[0])
  532. file.target.value = null // 注意上传后要将input的值设为空
  533. const workBook = xlsx.read(dataBinary, {
  534. type: 'binary',
  535. cellDates: true
  536. })
  537. const workSheet = workBook.Sheets[workBook.SheetNames[0]]
  538. const data = xlsx.utils.sheet_to_json(workSheet)
  539. const importData = this.switchDeviceObj(data, this.columns)
  540. // console.log(JSON.parse(JSON.stringify(importData)))
  541. // this.checkDate(importData)
  542. await this.switchXmToId(importData)
  543. this.tableData.push(...importData)
  544. // console.log(JSON.parse(JSON.stringify(this.tableData)))
  545. } catch (error) {
  546. this.$message.warning(error?.message || '导入失败')
  547. }
  548. },
  549. getTimeStamp() {
  550. return dayjs().format('YYYYMMDDHHmmss')
  551. },
  552. onExportClick() {
  553. // const btn = document.querySelector('.dynamic-form-table .ibps-icon-export')
  554. // btn.click()
  555. const copyData = JSON.parse(JSON.stringify(this.tableData))
  556. this.xlsx(
  557. copyData,
  558. this.columns,
  559. '定量项目室内质控月分析表' + this.getTimeStamp()
  560. )
  561. this.$message.success('导出成功!')
  562. },
  563. onRemoveClick() {
  564. if (this.multipleSelection.length === 0) {
  565. return this.$message.warning('请先选择需要删除的数据!')
  566. }
  567. this.$confirm('是否确认删除所选项?', '提示', {
  568. confirmButtonText: '确认',
  569. cancelButtonText: '取消',
  570. type: 'warning'
  571. })
  572. .then(() => {
  573. this.tableData = this.tableData.filter(
  574. (item) => !this.multipleSelection.includes(item)
  575. )
  576. this.currentPage = 1
  577. })
  578. .catch(() => {})
  579. },
  580. onEditClick(row, $index) {
  581. const btns = document.querySelectorAll(
  582. '.dynamic-form-table .ibps-icon-edit'
  583. )
  584. btns[Math.floor(btns.length / 2) + $index].click()
  585. },
  586. onPageClick(number) {
  587. const btns = document.querySelectorAll(
  588. '.dynamic-form-table .el-pager .number'
  589. )
  590. if (btns[0].innerText == this.currentPage) {
  591. btns[0].click()
  592. }
  593. if (btns[1].innerText == this.currentPage) {
  594. btns[1].click()
  595. }
  596. if (btns[2].innerText == this.currentPage) {
  597. btns[2].click()
  598. }
  599. if (btns[3].innerText == this.currentPage) {
  600. btns[3].click()
  601. }
  602. if (btns[4].innerText == this.currentPage) {
  603. btns[4].click()
  604. }
  605. if (btns[5].innerText == this.currentPage) {
  606. btns[5].click()
  607. }
  608. if (btns[6].innerText == this.currentPage) {
  609. btns[6].click()
  610. }
  611. const butprev = document.querySelectorAll(
  612. '.dynamic-form-table .el-pager .btn-quickprev'
  613. )
  614. if (
  615. this.currentPage < Number(btns[1].innerText) &&
  616. this.currentPage !== Number(btns[0].innerText)
  617. ) {
  618. butprev[0].click()
  619. }
  620. const butnext = document.querySelectorAll(
  621. '.dynamic-form-table .el-pager .btn-quicknext'
  622. )
  623. if (
  624. this.currentPage > Number(btns[5].innerText) &&
  625. this.currentPage !== Number(btns[6].innerText)
  626. ) {
  627. butnext[0].click()
  628. }
  629. },
  630. onSizeClick() {
  631. const names = document.querySelectorAll(
  632. '.dynamic-form-table .el-popper .el-select-dropdown__item'
  633. )
  634. if (names[0].innerText == this.pageSize + '条/页') {
  635. names[0].click()
  636. }
  637. if (names[1].innerText == this.pageSize + '条/页') {
  638. names[1].click()
  639. }
  640. if (names[2].innerText == this.pageSize + '条/页') {
  641. names[2].click()
  642. }
  643. if (names[3].innerText == this.pageSize + '条/页') {
  644. names[3].click()
  645. }
  646. if (names[4].innerText == this.pageSize + '条/页') {
  647. names[4].click()
  648. }
  649. if (names[5].innerText == this.pageSize + '条/页') {
  650. names[5].click()
  651. }
  652. },
  653. // 当前页码改变
  654. handleCurrentChange(val) {
  655. this.currentPage = val
  656. this.onPageClick()
  657. },
  658. // 页码选择器改变
  659. handleSizeChange(val) {
  660. this.pageSize = val
  661. this.currentPage = 1
  662. this.onSizeClick()
  663. }
  664. }
  665. }
  666. </script>
  667. <style lang="scss" scoped>
  668. .qualityControl {
  669. margin-top: 20px;
  670. .btn {
  671. padding: 0;
  672. margin-bottom: 4px;
  673. display: flex;
  674. justify-content: flex-end;
  675. .el-button + .el-button {
  676. margin-left: 6px;
  677. }
  678. }
  679. }
  680. </style>