fromtableDetails.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div>
  3. <el-table
  4. ref="tableRef"
  5. :cell-style="{ padding: '0px', fontSize: '12px' }"
  6. :header-cell-style="tableHeaderCellStyle"
  7. :data="tableData"
  8. :border="true"
  9. show-summary
  10. :summary-method="summaryMethod"
  11. style="width: 100%"
  12. @selection-change="handleSelectionChange"
  13. @row-click="rowClick"
  14. :row-style="rowStyle"
  15. :row-class-name="rowClassName"
  16. >
  17. <el-table-column fixed="left" type="selection" width="50"> </el-table-column>
  18. <el-table-column type="index" width="40" style="text-align: center"> </el-table-column>
  19. <el-table-column prop="descr" label="摘要" width="auto" style="padding: 0">
  20. <template slot-scope="{ row }">
  21. <!-- type="textarea"-->
  22. <el-input
  23. style="width: 100%"
  24. type="text"
  25. v-model="row.descr"
  26. size="small"
  27. autocomplete="off"
  28. clearable
  29. placeholder="请输入摘要"
  30. :disabled="disabled"
  31. >
  32. </el-input>
  33. </template>
  34. </el-table-column>
  35. <el-table-column prop="accountCode" label="科目代码" width="360px">
  36. <template slot-scope="{ row }">
  37. <div
  38. style="display: flex; align-items: center; justify-content: space-between"
  39. >
  40. <search-query
  41. style="width: 100%"
  42. :datalist="accountData"
  43. :selectValue="row.accountCode"
  44. :filterable="true"
  45. :clearable="true"
  46. :remote="true"
  47. :buttonIf="false"
  48. :desc="true"
  49. :forParameter="{ key: 'code', label: 'code', value: 'code', desc: 'fullName' }"
  50. :disabled="disabled"
  51. @corpFocus="accountsListfun"
  52. @remoteMethod="accountsListfun"
  53. @corpChange="corpChange($event, 'accountId', row)"
  54. >
  55. </search-query>
  56. <el-tooltip v-if="!disabled &&(row.isEmpl===1 || row.isCorp === 1 || row.isDept === 1 || row.isItem === 1)" class="item" effect="dark" content="核算项目" placement="top">
  57. <el-button size="mini" type="primary" icon="el-icon-edit" circle @click="auxiliaryAccountingfun(row)" :disabled="disabled"></el-button>
  58. </el-tooltip>
  59. <el-tooltip v-if="!disabled && row.isDc === 1" class="item" effect="dark" content="预收/预付核销" placement="top">
  60. <el-button size="mini" type="primary" icon="el-icon-scissors" circle @click="showOffRecordsfun(row)" :disabled="disabled"></el-button>
  61. </el-tooltip>
  62. </div>
  63. <div style="display: flex">
  64. <!-- _【职员】 _【部门】 _【客户】-->
  65. <span>{{
  66. (row.accountCnName ? row.accountCnName : " ") +
  67. (row.isEmpl === 1 && row.emplName ? "/" + row.emplName : "") +
  68. (row.isDept === 1 && row.deptName ? "/" + row.deptName : "") +
  69. (row.isCorp === 1 && row.corpShortName ? "/" + row.corpShortName : "") +
  70. (row.isItem === 1 ? "/" + row.itemClassify + "-" + (row.itemName ? row.itemName : "") : "")
  71. }}</span>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. <el-table-column prop="dc" label="方向" width="60px" style="padding: 0">
  76. <template slot-scope="{ row }">
  77. <span>{{ row.dc == 'D' ? '借' : '贷' }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="本币金额">
  81. <el-table-column prop="amountDr" label="借方" width="120px">
  82. <template slot-scope="{ row }">
  83. <el-input-number
  84. style="width: 100%"
  85. v-model="row.amountDr"
  86. size="small"
  87. autocomplete="off"
  88. :disabled="!row.accountId || disabled"
  89. placeholder="请输入借方"
  90. :precision="2"
  91. @change="amountBlur(row, 'D')"
  92. @keydown.native="handleKeydown($event, row,'amountDr')"
  93. :controls="false"
  94. >
  95. </el-input-number>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="amountCr" label="货方" width="120px">
  99. <template slot-scope="{ row }">
  100. <el-input-number
  101. style="width: 100%"
  102. v-model="row.amountCr"
  103. size="small"
  104. autocomplete="off"
  105. :disabled="!row.accountId || disabled"
  106. placeholder="请输入货方"
  107. :precision="2"
  108. @change="amountBlur(row, 'C')"
  109. @keydown.native="handleKeydown($event, row,'amountCr')"
  110. :controls="false"
  111. >
  112. </el-input-number>
  113. </template>
  114. </el-table-column>
  115. </el-table-column>
  116. <el-table-column label="外币金额">
  117. <el-table-column prop="curCode" label="币种" width="80px" align="center"> </el-table-column>
  118. <el-table-column prop="exrate" label="汇率" width="100px">
  119. <template slot-scope="{ row }">
  120. <el-input-number
  121. v-if="row.curCode === 'USD'"
  122. style="width: 100%"
  123. v-model="row.exrate"
  124. size="small"
  125. autocomplete="off"
  126. clearable
  127. placeholder="请输入借方"
  128. :precision="4"
  129. @change="amountBlur(row, 'exrate')"
  130. :disabled="disabled"
  131. :controls="false"
  132. >
  133. </el-input-number>
  134. <!-- {{ row.exrate }}-->
  135. <span v-else></span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column prop="amountDrUsd" label="借方" width="120px">
  139. <template slot-scope="{ row }">
  140. <el-input-number
  141. v-if="row.changeMode !== 'd'"
  142. style="width: 100%; text-align: right"
  143. v-model="row.amountDrUsd"
  144. size="small"
  145. autocomplete="off"
  146. :disabled="row.curCode === 'CNY' || !row.accountId || disabled"
  147. clearable
  148. placeholder="请输入借方"
  149. :precision="2"
  150. @change="amountUSDBlur(row, 'Dusd')"
  151. :controls="false"
  152. >
  153. </el-input-number>
  154. </template>
  155. </el-table-column>
  156. <el-table-column prop="amountCrUsd" label="货方" width="120px">
  157. <template slot-scope="{ row }">
  158. <el-input-number
  159. v-if="row.changeMode !== 'd'"
  160. style="width: 100%"
  161. v-model="row.amountCrUsd"
  162. size="small"
  163. autocomplete="off"
  164. :disabled="row.curCode === 'CNY' || !row.accountId || disabled"
  165. clearable
  166. placeholder="请输入货方"
  167. :precision="2"
  168. @change="amountUSDBlur(row, 'Cusd')"
  169. :controls="false"
  170. >
  171. </el-input-number>
  172. </template>
  173. </el-table-column>
  174. </el-table-column>
  175. <!--
  176. <el-table-column prop="remarks" label="备注" width="200px">
  177. <template slot-scope="{ row }">
  178. <el-input
  179. style="width: 100%;"
  180. type="textarea"
  181. v-model="row.remarks"
  182. size="small"
  183. autocomplete="off"
  184. clearable
  185. placeholder="请输入备注"
  186. :disabled="disabled"
  187. >
  188. </el-input>
  189. </template>
  190. </el-table-column>
  191. -->
  192. <el-table-column v-if="!disabled" label="操作" fixed="right" width="100px">
  193. <template slot-scope="scope">
  194. <el-tooltip class="item" effect="dark" content="添加" placement="top">
  195. <el-button
  196. size="mini"
  197. type="primary"
  198. icon="el-icon-plus"
  199. circle
  200. @click="addRowsfun(scope.row, scope.$index)"
  201. :disabled="disabled"
  202. ></el-button>
  203. </el-tooltip>
  204. <el-tooltip class="item" effect="dark" :content="scope.row.changeMode === 'd' ? '恢复' : '删除'" placement="top">
  205. <el-button
  206. size="mini"
  207. type="danger"
  208. icon="el-icon-delete"
  209. circle
  210. @click="deletefun(scope.row, scope.$index)"
  211. :disabled="disabled"
  212. ></el-button>
  213. </el-tooltip>
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. </div>
  218. </template>
  219. <script>
  220. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  221. import { accountsList } from "@/api/iosBasicData/accounts";
  222. import { bcurrencyGetExrate } from "@/api/iosBasicData/rateManagement";
  223. import { dateFormat } from "@/util/date";
  224. export default {
  225. components: { SearchQuery },
  226. data() {
  227. return {
  228. accountData: [], // 科目数据
  229. };
  230. },
  231. props: {
  232. assemblyForm: {
  233. type: Object,
  234. default: {},
  235. },
  236. tableData: {
  237. type: Array,
  238. default: [],
  239. },
  240. handleSelectionData: {
  241. type: Array,
  242. default: [],
  243. },
  244. disabled: {
  245. type: Boolean,
  246. default: false,
  247. },
  248. },
  249. async created() {
  250. this.accountsListfun();
  251. // this.option = await this.getColumnData(this.getColumnName(321.1), this.optionBack);
  252. },
  253. methods: {
  254. forceNumber(s, d){
  255. let N = Number(s);
  256. return isNaN(N) ? 0.00 : Number(N.toFixed(d));
  257. },
  258. // 自定义合计
  259. summaryMethod(param) {
  260. const { columns, data } = param;
  261. const sums = [];
  262. columns.forEach((column, index) => {
  263. if (index === 2) {
  264. sums[index] = "合计";
  265. return;
  266. }
  267. const values = data.map((item) => item.changeMode === 'd' ? 0.00 : Number(item[column.property]));
  268. // 显示列的统计 金额
  269. let arr = ["amountDr", "amountCr", "amountDrUsd", "amountCrUsd"];
  270. // 判断是否有这个数据
  271. if (arr.indexOf(column.property) != -1) {
  272. if (!values.every((value) => isNaN(value))) {
  273. sums[index] = values.reduce((prev, curr) => {
  274. const value = Number(curr);
  275. if (!isNaN(value)) {
  276. return prev + curr;
  277. } else {
  278. return prev;
  279. }
  280. }, 0);
  281. sums[index] = sums[index].toFixed(2); // 把合计的参数保留两位小数
  282. // sums[index] += " 元";
  283. } else {
  284. sums[index] = " ";
  285. }
  286. }
  287. });
  288. return sums;
  289. },
  290. handleKeydown(e, row, name){
  291. console.log("handleKeydown", e, name);
  292. if(e.key === "="){
  293. e.preventDefault();
  294. // amountDr,amountCr
  295. let amtDr = 0.00, amtCr = 0.00;
  296. this.tableData.forEach((item) => {
  297. if(item!==row){
  298. amtDr = this.forceNumber(amtDr + item.amountDr, 2);
  299. amtCr = this.forceNumber(amtCr + item.amountCr, 2);
  300. }
  301. })
  302. if(name==='amountDr'){
  303. this.$set(row, "amountCr", 0.00)
  304. this.$set(row, name, this.forceNumber(amtCr - amtDr, 2))
  305. }
  306. if(name==='amountCr'){
  307. this.$set(row, "amountDr", 0.00)
  308. this.$set(row, name, this.forceNumber(amtDr - amtCr, 2))
  309. }
  310. if(row.curCode==="USD"){
  311. if(row.exrate.toFixed(4)==='0.0000'){
  312. row.exrate = 1
  313. }
  314. this.$set(row, "amountDrUsd", this.forceNumber(row.amountDr / row.exrate, 2))
  315. this.$set(row, "amountCrUsd", this.forceNumber(row.amountCr / row.exrate, 2))
  316. }
  317. }
  318. },
  319. // 借方/贷方 本币的计算
  320. amountBlur(row, name) {
  321. console.log("amountBlur", row, name);
  322. if (name == "D") {
  323. this.$set(row, "amountCr", 0);
  324. }
  325. if (name == "C") {
  326. this.$set(row, "amountDr", 0);
  327. }
  328. // if (name == 'Dusd') {
  329. // this.$set(row,'amountCrUsd',0)
  330. // }
  331. // if (name == 'Cusd') {
  332. // this.$set(row,'amountDrUsd',0)
  333. // }
  334. if (row.curCode == "USD") {
  335. this.$set(row, "exrate", row.exrate ? Number(row.exrate) : 1);
  336. this.$set(row, "amountCr", row.amountCr ? Number(row.amountCr) : 0);
  337. this.$set(row, "amountDr", row.amountDr ? Number(row.amountDr) : 0);
  338. this.$set(row, "amountCrUsd", (row.amountCr / row.exrate).toFixed(2));
  339. this.$set(row, "amountDrUsd", (row.amountDr / row.exrate).toFixed(2));
  340. }
  341. },
  342. // 外币的计算
  343. amountUSDBlur(row, name) {
  344. console.log("amountUSDBlur", row, name);
  345. if (name == "Dusd") {
  346. this.$set(row, "amountCrUsd", 0);
  347. }
  348. if (name == "Cusd") {
  349. this.$set(row, "amountDrUsd", 0);
  350. }
  351. this.$set(row, "exrate", row.exrate ? Number(row.exrate) : 1);
  352. this.$set(row, "amountCrUsd", row.amountCrUsd ? Number(row.amountCrUsd) : 0);
  353. this.$set(row, "amountDrUsd", row.amountDrUsd ? Number(row.amountDrUsd) : 0);
  354. this.$set(row, "amountCr", (row.amountCrUsd * row.exrate).toFixed(2));
  355. this.$set(row, "amountDr", (row.amountDrUsd * row.exrate).toFixed(2));
  356. },
  357. // 获取科目类型数据
  358. accountsListfun(code) {
  359. // isManual == 1 的允许手工添加
  360. accountsList(1, 10, { code, isDetail: 1, isManual: 1 }).then((res) => {
  361. console.log(res.data.data.records);
  362. this.accountData = res.data.data.records;
  363. });
  364. },
  365. // 行删除
  366. deletefun(row, index) {
  367. this.$emit("deletefun", row, index);
  368. },
  369. // 行添加
  370. addRowsfun(row, index) {
  371. this.$emit("addRowsfun", row, index);
  372. },
  373. // 辅助核算
  374. auxiliaryAccountingfun(row) {
  375. if (!row.accountId) {
  376. return this.$message.warning("请先选择科目代码");
  377. }
  378. this.$emit("auxiliaryAccountingfun", row);
  379. },
  380. showOffRecordsfun (row){
  381. if (!row.accountId) {
  382. return this.$message.warning("请先选择科目代码");
  383. }
  384. this.$emit("showOffRecordsfun", row);
  385. },
  386. // 下拉回调
  387. corpChange(value, name, row) {
  388. let found = false;
  389. if (name === "accountId") {
  390. for (let item of this.accountData) {
  391. console.log(item);
  392. if (item.code == value) {
  393. found = true;
  394. console.log(item, item.id);
  395. this.$set(row, "accountId", item.id);
  396. this.$set(row, "accountCode", item.code);
  397. this.$set(row, "accountCnName", item.cnName);
  398. this.$set(row, "accountEnName", item.enName);
  399. this.$set(row, "accountFullName", item.fullName);
  400. this.$set(row, "accountLevel", item.level);
  401. this.$set(row, "accountProperty", item.property);
  402. this.$set(row, "dc", item.dc);
  403. // 币种
  404. this.$set(row, "curCode", item.curCode==="USD" ? item.curCode : "CNY");
  405. // 汇率
  406. this.$set(row, "exrate", item.exrate);
  407. // 其他
  408. this.$set(row, "isForeign", item.isForeign);
  409. this.$set(row, "isQuantity", item.isQuantity);
  410. this.$set(row, "isCorp", item.isCorp);
  411. this.$set(row, "isDept", item.isDept);
  412. this.$set(row, "isEmpl", item.isEmpl);
  413. this.$set(row, "isItem", item.isItem);
  414. this.$set(row, "itemClassifyId", item.itemClassifyId);
  415. this.$set(row, "itemClassify", item.itemClassify);
  416. this.$set(row, "isDc", item.isDc);
  417. this.$set(row, "isArAp", item.isArAp);
  418. // 打开弹窗
  419. this.$emit("auxiliaryAccountingfun", row);
  420. }
  421. }
  422. if (!found) {
  423. console.log("not found");
  424. this.$set(row, "accountId", 0);
  425. this.$set(row, "accountCode", "");
  426. this.$set(row, "accountCnName", "");
  427. this.$set(row, "accountEnName", "");
  428. this.$set(row, "accountFullName", "");
  429. this.$set(row, "accountLevel", 0);
  430. this.$set(row, "accountProperty", 0);
  431. this.$set(row, "dc", "");
  432. // 币种
  433. this.$set(row, "curCode", "");
  434. // 汇率
  435. // 其他
  436. this.$set(row, "isForeign", 0);
  437. this.$set(row, "isQuantity", 0);
  438. this.$set(row, "isCorp", 0);
  439. this.$set(row, "isDept", 0);
  440. this.$set(row, "isEmpl", 0);
  441. this.$set(row, "isItem", 0);
  442. this.$set(row, "itemClassifyId", 0);
  443. this.$set(row, "itemClassify", "");
  444. this.$set(row, "isDc", 0);
  445. this.$set(row, "isArAp", 0);
  446. this.$set(row, "exrate", 0);
  447. }
  448. if (row.curCode === "USD") {
  449. bcurrencyGetExrate({
  450. date: this.assemblyForm.voucherDate ? this.assemblyForm.voucherDate.slice(0, 10) + " 00:00:00" : dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00", // 凭证日期
  451. dc: row.dc,
  452. type: 1,
  453. }).then((res) => {
  454. for (let item of res.data.data) {
  455. if (item.code === row.curCode) {
  456. this.$set(row, "exrate", this.forceNumber(item.exrate, 4));
  457. this.$set(row, "amountDr", this.forceNumber(row.amountDr, 2))
  458. this.$set(row, "amountCr", this.forceNumber(row.amountCr, 2))
  459. this.$set(row, "amountDrUsd", this.forceNumber(row.amountDrUsd, 2))
  460. this.$set(row, "amountCrUsd", this.forceNumber(row.amountCrUsd, 2))
  461. if(row.amountDrUsd!==0.00){
  462. this.$set(row, "amountCrUsd", 0.00)
  463. this.$set(row, "amountCr", 0.00)
  464. this.$set(row, "amountDr", this.forceNumber(row.amountDrUsd * item.exrate, 2))
  465. }else{
  466. this.$set(row, "amountDrUsd", 0.00)
  467. this.$set(row, "amountDr", 0.00)
  468. this.$set(row, "amountCr", this.forceNumber(row.amountCrUsd * item.exrate, 2))
  469. }
  470. }
  471. }
  472. });
  473. } else {
  474. this.$set(row, "exrate", 0);
  475. this.$set(row, "amountDrUsd", 0.00);
  476. this.$set(row, "amountCrUsd", 0.00);
  477. }
  478. }
  479. console.log(row);
  480. },
  481. // 表头样式
  482. tableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
  483. return "padding:4px 0px;fontSize:12px;color:#000;background:#ecf5ff;text-align:center";
  484. },
  485. // 列表多选
  486. // 多选选择的数据
  487. handleSelectionChange(arr) {
  488. this.$emit("handleSelectionChange", arr);
  489. },
  490. // 监听点击表格事件
  491. rowClick(row, column, event) {
  492. let refsElTable = this.$refs.tableRef; // 获取表格对象
  493. if (this.CtrlDown) {
  494. refsElTable.toggleRowSelection(row); // ctrl多选 如果点击两次同样会取消选中
  495. return;
  496. }
  497. if (this.shiftOrAltDown && this.handleSelectionData.length > 0) {
  498. // 通过rowIndex判断已选择的行中最上面和最下面的是哪行,再对比按住shift/alt点击的当前行得到新的最上面和最下面的行,把这两行中间的行进行循环选中。
  499. let topAndBottom = this.getTopAndBottom(row, this.bottomSelectionRow, this.topSelectionRow);
  500. refsElTable.clearSelection(); //先清空 不然会导致在这两行中间之外的行状态不变
  501. for (let index = topAndBottom.top; index <= topAndBottom.bottom; index++) {
  502. //选中两行之间的所有行
  503. refsElTable.toggleRowSelection(this.tableData[index], true);
  504. }
  505. } else {
  506. let findRow = this.handleSelectionData.find((c) => c.rowIndex == row.rowIndex); //找出当前选中行
  507. //如果只有一行且点击的也是这一行则取消选择 否则清空再选中当前点击行
  508. if (findRow && this.handleSelectionData.length === 1) {
  509. refsElTable.toggleRowSelection(row, false);
  510. return;
  511. }
  512. // refsElTable.clearSelection(); // 清空之前选择的数据(如果放开,选择之前会变成单选)
  513. refsElTable.toggleRowSelection(row); // 调用选中行方法
  514. }
  515. },
  516. // 行的 style 的回调方法
  517. rowStyle({ row, rowIndex }) {
  518. // 直接在一个对象上定义一个新属性,或者修改一个对象的现有属性,并返回此对象
  519. // object: 要添加或者修改属性的目标对象;prop: 要定义或修改属性的名称;descript: 是一个对象,里面是我们上述的对象属性的特性;
  520. Object.defineProperty(row, "rowIndex", {
  521. //给每一行添加不可枚举属性rowIndex来标识当前行
  522. value: rowIndex, // 设置age的值,不设置的话默认为undefined
  523. writable: true, // 表示属性的值true可以修改,false不可以被修改
  524. enumerable: false, // 设置为false表示不能通过 for-in 循环返回
  525. // configurable: false, // configurable 设置为 false,意味着这个属性不能从对象上删除
  526. });
  527. },
  528. keyDown(event) {
  529. let key = event.keyCode;
  530. if (key == 17) this.CtrlDown = true;
  531. if (key == 16 || key == 18) this.shiftOrAltDown = true;
  532. },
  533. keyUp(event) {
  534. let key = event.keyCode;
  535. if (key == 17) this.CtrlDown = false;
  536. if (key == 16 || key == 18) this.shiftOrAltDown = false;
  537. },
  538. // 文章说明 https://www.jianshu.com/p/48f2c522d2a2
  539. getTopAndBottom(row, bottom, top) {
  540. let n = row.rowIndex,
  541. mx = bottom.rowIndex,
  542. mi = top.rowIndex;
  543. if (n > mx) {
  544. return {
  545. top: mi,
  546. bottom: n,
  547. };
  548. } else if (n < mx && n > mi) {
  549. return {
  550. top: mi,
  551. bottom: n,
  552. };
  553. } else if (n < mi) {
  554. return {
  555. top: n,
  556. bottom: mx,
  557. };
  558. } else if (n == mi || n == mx) {
  559. return {
  560. top: mi,
  561. bottom: mx,
  562. };
  563. }
  564. },
  565. // 给选中行加上current-row这个class类,所以要使用row-class-name这个属性(其实给每一行添加rowIndex也可以用这个属性),
  566. // 判断方式也是通过判断rowIndex对比
  567. rowClassName({ row, rowIndex }) {
  568. let rowName = "",
  569. findRow = this.handleSelectionData.find((c) => c.rowIndex === row.rowIndex);
  570. if (findRow) {
  571. rowName = "current-row "; // elementUI 默认高亮行的class类 不用再样式了^-^,也可通过css覆盖改变背景颜色
  572. }
  573. return rowName; //也可以再加上其他类名 如果有需求的话
  574. },
  575. },
  576. mounted() {
  577. // 按住ctrl实现多选 设置监听keydown事件,以及keyup事件,
  578. addEventListener("keydown", this.keyDown, false);
  579. addEventListener("keyup", this.keyUp, false);
  580. },
  581. beforeDestroy() {
  582. //解绑
  583. removeEventListener("keydown", this.keyDown);
  584. removeEventListener("keyup", this.keyUp);
  585. },
  586. computed: {
  587. //实时得到最上行和最下行
  588. bottomSelectionRow() {
  589. if (this.handleSelectionData.length == 0) return null;
  590. return this.handleSelectionData.reduce((start, end) => {
  591. return start.rowIndex > end.rowIndex ? start : end;
  592. });
  593. },
  594. topSelectionRow() {
  595. if (this.handleSelectionData.length == 0) return null;
  596. return this.handleSelectionData.reduce((start, end) => {
  597. return start.rowIndex < end.rowIndex ? start : end;
  598. });
  599. },
  600. },
  601. };
  602. </script>
  603. <style scoped>
  604. ::v-deep input::-webkit-outer-spin-button,
  605. ::v-deep input::-webkit-inner-spin-button {
  606. -webkit-appearance: none !important;
  607. }
  608. ::v-deep input[type="number"] {
  609. -moz-appearance: textfield !important;
  610. }
  611. ::v-deep .el-table td {
  612. padding: 0;
  613. }
  614. ::v-deep .el-input-number .el-input__inner {
  615. text-align: right;
  616. }
  617. </style>