accitemsopenblc.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. <template>
  2. <div>
  3. <!-- @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 323.1)"-->
  4. <!-- @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 323.1)"-->
  5. <avue-crud
  6. id="out-table"
  7. ref="crud"
  8. :option="option"
  9. :table-loading="loading"
  10. :data="form.accItemsOpenblcList"
  11. :cell-style="{ padding: '0px' }"
  12. :header-cell-class-name="headerClassName"
  13. :row-style="{ height: '20px' }"
  14. @selection-change="selectionChange"
  15. >
  16. <template slot="menuLeft">
  17. <el-button type="primary" size="small" :disabled="!getCanModify" icon="el-icon-plus" @click="addButtonfun">新 增 </el-button>
  18. <el-button type="danger" size="small" icon="el-icon-delete" plain :disabled="!getCanModify" @click="handleDelete">删 除 </el-button>
  19. <!-- <span>{{ form }}<br />getCanModify:{{ getCanModify() }}<br />option:{{ option }}</span>-->
  20. </template>
  21. <template v-if="form.isCorp == 1" slot="corpShortName" slot-scope="{ row }">
  22. <search-query
  23. v-if="row.edit"
  24. :datalist="corpData"
  25. :selectValue="row.shortName"
  26. :filterable="true"
  27. :clearable="true"
  28. :remote="true"
  29. :buttonIf="false"
  30. placeholder="请选择客户名称"
  31. :forParameter="{ key: 'id', label: 'shortName', value: 'shortName' }"
  32. @remoteMethod="corpBcorpsListfun"
  33. @corpChange="corpChange($event, 'shortName', row)"
  34. @corpFocus="corpBcorpsListfun"
  35. >
  36. </search-query>
  37. <span v-else>{{ row.corpCnName }}</span>
  38. </template>
  39. <template v-if="form.isDept == 1" slot="deptName" slot-scope="{ row }">
  40. <tree-select
  41. v-if="row.edit"
  42. v-model="row.deptName"
  43. filterable
  44. :data="deptData"
  45. :props="{ label: 'title', children: 'children' }"
  46. nodeKey="title"
  47. size="small"
  48. :multiple="false"
  49. placeholder="请选择部门名称"
  50. @selectChange="corpChange($event, 'deptName', row)"
  51. @focus="deptDeptLazyTreefun"
  52. >
  53. </tree-select>
  54. <span v-else>{{ row.deptName }}</span>
  55. </template>
  56. <template v-if="form.isEmpl == 1" slot="emplName" slot-scope="{ row }">
  57. <search-query
  58. v-if="row.edit"
  59. :datalist="emplData"
  60. :selectValue="row.emplName"
  61. :filterable="true"
  62. :clearable="true"
  63. :remote="true"
  64. :buttonIf="false"
  65. placeholder="请选择职工名称"
  66. :forParameter="{ key: 'id', label: 'name', value: 'name' }"
  67. @remoteMethod="userPagelistfun"
  68. @corpChange="corpChange($event, 'emplName', row)"
  69. @corpFocus="userPagelistfun"
  70. >
  71. </search-query>
  72. <span v-else>{{ row.emplName }}</span>
  73. </template>
  74. <template v-if="form.isItem == 1" slot="itemName" slot-scope="{ row }">
  75. <search-query
  76. v-if="row.edit"
  77. :datalist="itemData"
  78. :selectValue="row.itemName"
  79. :filterable="true"
  80. :clearable="true"
  81. :remote="true"
  82. :buttonIf="false"
  83. placeholder="请选择核算项目"
  84. :forParameter="{ key: 'id', label: 'cnName', value: 'cnName' }"
  85. @remoteMethod="baccitemstypeListfun"
  86. @corpChange="corpChange($event, 'itemName', row)"
  87. @corpFocus="baccitemstypeListfun"
  88. >
  89. </search-query>
  90. <span v-else>{{ row.itemName }}</span>
  91. </template>
  92. <template slot="amountOpenDr" slot-scope="{ row }">
  93. <el-input-number
  94. v-if="row.edit"
  95. style="width: 100%"
  96. v-model="row.amountOpenDr"
  97. size="small"
  98. autocomplete="off"
  99. clearable
  100. placeholder="请输入年初借方金额"
  101. :precision="2"
  102. :controls="false"
  103. value-on-clear="0"
  104. align="right"
  105. @change="amountChange(row, 'amountOpenDr')"
  106. >
  107. </el-input-number>
  108. <span v-else>{{ fmtAmt(row.amountOpenDr) }}</span>
  109. </template>
  110. <template slot="amountOpenCr" slot-scope="{ row }">
  111. <el-input-number
  112. v-if="row.edit"
  113. style="width: 100%"
  114. v-model="row.amountOpenCr"
  115. size="small"
  116. autocomplete="off"
  117. clearable
  118. placeholder="请输入年初贷方金额"
  119. :precision="2"
  120. :controls="false"
  121. value-on-clear="0"
  122. align="right"
  123. @change="amountChange(row, 'amountOpenCr')"
  124. >
  125. </el-input-number>
  126. <span v-else>{{ fmtAmt(row.amountOpenCr) }}</span>
  127. </template>
  128. <template slot="amountDr" slot-scope="{ row }">
  129. <el-input-number
  130. v-if="row.edit"
  131. style="width: 100%"
  132. v-model="row.amountDr"
  133. size="small"
  134. autocomplete="off"
  135. clearable
  136. placeholder="请输入本年借方金额"
  137. :precision="2"
  138. :controls="false"
  139. value-on-clear="0"
  140. align="right"
  141. @change="amountChange(row, 'amountDr')"
  142. >
  143. </el-input-number>
  144. <span v-else>{{ fmtAmt(row.amountDr) }}</span>
  145. </template>
  146. <template slot="amountCr" slot-scope="{ row }">
  147. <el-input-number
  148. v-if="row.edit"
  149. style="width: 100%"
  150. v-model="row.amountCr"
  151. size="small"
  152. autocomplete="off"
  153. clearable
  154. placeholder="请输入本年贷方金额"
  155. :precision="2"
  156. :controls="false"
  157. value-on-clear="0"
  158. align="right"
  159. @change="amountChange(row, 'amountCr')"
  160. >
  161. </el-input-number>
  162. <span v-else>{{ fmtAmt(row.amountCr) }}</span>
  163. </template>
  164. <template slot="amountOpenDrUsd" slot-scope="{ row }">
  165. <el-input-number
  166. v-if="row.edit"
  167. style="width: 100%"
  168. v-model="row.amountOpenDrUsd"
  169. size="small"
  170. autocomplete="off"
  171. clearable
  172. placeholder="请输入外币年初借方金额"
  173. :precision="2"
  174. :controls="false"
  175. value-on-clear="0"
  176. align="right"
  177. @change="amountChange(row, 'amountOpenDrUsd')"
  178. >
  179. </el-input-number>
  180. <span v-else>{{ fmtAmt(row.amountOpenDrUsd) }}</span>
  181. </template>
  182. <template slot="amountOpenCrUsd" slot-scope="{ row }">
  183. <el-input-number
  184. v-if="row.edit"
  185. style="width: 100%"
  186. v-model="row.amountOpenCrUsd"
  187. size="small"
  188. autocomplete="off"
  189. clearable
  190. placeholder="请输入外币年初贷方金额"
  191. :precision="2"
  192. :controls="false"
  193. value-on-clear="0"
  194. align="right"
  195. @change="amountChange(row, 'amountOpenCrUsd')"
  196. >
  197. </el-input-number>
  198. <span v-else>{{ fmtAmt(row.amountOpenCrUsd) }}</span>
  199. </template>
  200. <template slot="amountDrUsd" slot-scope="{ row }">
  201. <el-input-number
  202. v-if="row.edit"
  203. style="width: 100%"
  204. v-model="row.amountDrUsd"
  205. size="small"
  206. autocomplete="off"
  207. clearable
  208. placeholder="请输入外币本年借方金额"
  209. :precision="2"
  210. :controls="false"
  211. value-on-clear="0"
  212. align="right"
  213. @change="amountChange(row, 'amountDrUsd')"
  214. >
  215. </el-input-number>
  216. <span v-else>{{ fmtAmt(row.amountDrUsd) }}</span>
  217. </template>
  218. <template slot="amountCrUsd" slot-scope="{ row }">
  219. <el-input-number
  220. v-if="row.edit"
  221. style="width: 100%"
  222. v-model="row.amountCrUsd"
  223. size="small"
  224. autocomplete="off"
  225. clearable
  226. placeholder="请输入外币本年贷方金额"
  227. :precision="2"
  228. :controls="false"
  229. value-on-clear="0"
  230. align="right"
  231. @change="amountChange(row, 'amountCrUsd')"
  232. >
  233. </el-input-number>
  234. <span v-else>{{ fmtAmt(row.amountCrUsd) }}</span>
  235. </template>
  236. <template slot="quantityOpenDr" slot-scope="{ row }">
  237. <el-input-number
  238. v-if="row.edit"
  239. style="width: 100%"
  240. v-model="row.quantityOpenDr"
  241. size="small"
  242. autocomplete="off"
  243. clearable
  244. placeholder="请输入年初借方数量"
  245. :precision="2"
  246. :controls="false"
  247. value-on-clear="0"
  248. align="right"
  249. @change="amountChange(row, 'quantityOpenDr')"
  250. >
  251. </el-input-number>
  252. <span v-else>{{ fmtAmt(row.quantityOpenDr) }}</span>
  253. </template>
  254. <template slot="quantityOpenCr" slot-scope="{ row }">
  255. <el-input-number
  256. v-if="row.edit"
  257. style="width: 100%"
  258. v-model="row.quantityOpenCr"
  259. size="small"
  260. autocomplete="off"
  261. clearable
  262. placeholder="请输入年初贷方数量"
  263. :precision="2"
  264. :controls="false"
  265. value-on-clear="0"
  266. align="right"
  267. @change="amountChange(row, 'quantityOpenCr')"
  268. >
  269. </el-input-number>
  270. <span v-else>{{ fmtAmt(row.quantityOpenCr) }}</span>
  271. </template>
  272. <template slot="quantityDr" slot-scope="{ row }">
  273. <el-input-number
  274. v-if="row.edit"
  275. style="width: 100%"
  276. v-model="row.quantityDr"
  277. size="small"
  278. autocomplete="off"
  279. clearable
  280. placeholder="请输入本年借方数量"
  281. :precision="2"
  282. :controls="false"
  283. value-on-clear="0"
  284. align="right"
  285. @change="amountChange(row, 'quantityDr')"
  286. >
  287. </el-input-number>
  288. <span v-else>{{ fmtAmt(row.quantityDr) }}</span>
  289. </template>
  290. <template slot="quantityCr" slot-scope="{ row }">
  291. <el-input-number
  292. v-if="row.edit"
  293. style="width: 100%"
  294. v-model="row.quantityCr"
  295. size="small"
  296. autocomplete="off"
  297. clearable
  298. placeholder="请输入本年贷方数量"
  299. :precision="2"
  300. :controls="false"
  301. value-on-clear="0"
  302. align="right"
  303. @change="amountChange(row, 'quantityCr')"
  304. >
  305. </el-input-number>
  306. <span v-else>{{ fmtAmt(row.quantityCr) }}</span>
  307. </template>
  308. <template slot="menu" slot-scope="{ row }" v-if="getCanModify">
  309. <el-button type="text" size="small" v-if="row.edit" @click="editFun(row)">保存 </el-button>
  310. <el-button type="text" size="small" v-else @click="editFun(row)">编辑 </el-button>
  311. <el-button type="text" size="small" @click="rowDel(row)">删除 </el-button>
  312. </template>
  313. </avue-crud>
  314. </div>
  315. </template>
  316. <script>
  317. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  318. import { getBcorpslistByType } from "@/api/iosBasicData/bcorps";
  319. import { baccitemstypeList } from "@/api/iosBasicData/baccitemstype";
  320. import { getDeptTree } from "@/api/system/dept";
  321. import TreeSelect from "@/components/iosbasic-data/TreeSelect.vue";
  322. import { getList as userPagelist } from "@/api/system/user";
  323. import { accountsSubmit } from "@/api/iosBasicData/accounts";
  324. import { selectEmpls } from "@/api/approval/processConfig";
  325. export default {
  326. components: { TreeSelect, SearchQuery },
  327. props: {
  328. form: {
  329. type: Object,
  330. default: {},
  331. },
  332. },
  333. data() {
  334. return {
  335. corpData: [], // 客户数据
  336. deptData: [], // 部门名称数据
  337. emplData: [], // 员工数据
  338. itemData: [], // 核算项目
  339. multipleChoiceList: [], // 多选数据
  340. option: {
  341. height: "60vh",
  342. calcHeight: 30,
  343. tip: false,
  344. searchShow: true,
  345. searchMenuSpan: 6,
  346. border: true,
  347. index: true,
  348. selection: true,
  349. dialogClickModal: false,
  350. addBtn: false,
  351. viewBtn: false,
  352. delBtn: false,
  353. editBtn: false,
  354. menuWidth: 100,
  355. columnBtn: false, // 隐藏列设置
  356. refreshBtn: false, // 刷新按钮
  357. column: [],
  358. },
  359. loading: false,
  360. };
  361. },
  362. async created() {},
  363. methods: {
  364. buildOptionColumns() {
  365. let cols = [];
  366. if (this.form.isCorp == 1) {
  367. cols.push({
  368. label: "客户编号",
  369. prop: "corpCode",
  370. width: 120,
  371. });
  372. cols.push({
  373. label: "客户名称",
  374. prop: "corpShortName",
  375. width: 220,
  376. });
  377. }
  378. if (this.form.isDept == 1) {
  379. cols.push({
  380. label: "核算部门",
  381. prop: "deptName",
  382. width: 180,
  383. });
  384. }
  385. if (this.form.isEmpl == 1) {
  386. cols.push({
  387. label: "核算职员",
  388. prop: "emplName",
  389. width: 160,
  390. });
  391. }
  392. if (this.form.isItem == 1) {
  393. cols.push(
  394. {
  395. label: "核算项目类别",
  396. prop: "itemClassify",
  397. width: 160,
  398. },
  399. {
  400. label: "核算项目",
  401. prop: "itemName",
  402. width: 180,
  403. }
  404. );
  405. }
  406. cols.push({
  407. label: "本币期初",
  408. children: [
  409. {
  410. label: "年初借方",
  411. prop: "amountOpenDr",
  412. width: 120,
  413. align: "right",
  414. },
  415. {
  416. label: "年初贷方",
  417. prop: "amountOpenCr",
  418. width: 120,
  419. align: "right",
  420. },
  421. {
  422. label: "年初余额",
  423. prop: "amountOpenBlc",
  424. width: 120,
  425. align: "right",
  426. },
  427. {
  428. label: "本年借方",
  429. prop: "amountDr",
  430. width: 120,
  431. align: "right",
  432. },
  433. {
  434. label: "本年贷方",
  435. prop: "amountCr",
  436. width: 120,
  437. align: "right",
  438. },
  439. {
  440. label: "当前余额",
  441. prop: "amountBlc",
  442. width: 120,
  443. align: "right",
  444. },
  445. ],
  446. });
  447. if (this.form.isForeign == 1) {
  448. cols.push({
  449. label: "外币期初",
  450. children: [
  451. {
  452. label: "年初借方",
  453. prop: "amountOpenDrUsd",
  454. width: 120,
  455. align: "right",
  456. },
  457. {
  458. label: "年初贷方",
  459. prop: "amountOpenCrUsd",
  460. width: 120,
  461. align: "right",
  462. },
  463. {
  464. label: "年初余额",
  465. prop: "amountOpenUsdBlc",
  466. width: 120,
  467. align: "right",
  468. },
  469. {
  470. label: "本年借方",
  471. prop: "amountDrUsd",
  472. width: 120,
  473. align: "right",
  474. },
  475. {
  476. label: "本年贷方",
  477. prop: "amountCrUsd",
  478. width: 120,
  479. align: "right",
  480. },
  481. {
  482. label: "当前余额",
  483. prop: "amountUsdBlc",
  484. width: 120,
  485. align: "right",
  486. },
  487. ],
  488. });
  489. }
  490. if (this.form.isQuantity == 1) {
  491. cols.push({
  492. label: "数量期初",
  493. children: [
  494. {
  495. label: "年初借方",
  496. prop: "quantityOpenDr",
  497. width: 120,
  498. align: "right",
  499. },
  500. {
  501. label: "年初贷方",
  502. prop: "quantityOpenCr",
  503. width: 120,
  504. align: "right",
  505. },
  506. {
  507. label: "年初余额",
  508. prop: "quantityOpenBlc",
  509. width: 120,
  510. align: "right",
  511. },
  512. {
  513. label: "本年借方",
  514. prop: "quantityDr",
  515. width: 120,
  516. align: "right",
  517. },
  518. {
  519. label: "本年贷方",
  520. prop: "quantityCr",
  521. width: 120,
  522. align: "right",
  523. },
  524. {
  525. label: "当前余额",
  526. prop: "quantityBlc",
  527. width: 120,
  528. align: "right",
  529. },
  530. ],
  531. });
  532. }
  533. cols.push({
  534. label: "备注",
  535. prop: "remarks",
  536. });
  537. this.option.column = cols;
  538. },
  539. getCanModify() {
  540. if (this.form) {
  541. return this.form.isDetail && (this.form.isCorp == 1 || this.form.isDept == 1 || this.form.isEmpl == 1 || this.form.isItem == 1);
  542. } else {
  543. return false;
  544. }
  545. },
  546. // 添加
  547. addButtonfun() {
  548. this.form.accItemsOpenblcList.push({
  549. edit: true,
  550. });
  551. },
  552. // 多选
  553. selectionChange(list) {
  554. this.multipleChoiceList = list;
  555. },
  556. // 编辑
  557. editFun(row) {
  558. this.$set(row, "edit", !row.edit);
  559. },
  560. // 批量删除
  561. handleDelete() {
  562. this.$confirm("确定将选择数据删除?", {
  563. confirmButtonText: "确定",
  564. cancelButtonText: "取消",
  565. type: "warning",
  566. }).then(() => {
  567. for (let item of this.multipleChoiceList) {
  568. this.form.accItemsOpenblcList.splice(item.$index, 1);
  569. }
  570. this.$message.success("操作成功!");
  571. });
  572. },
  573. // 删除
  574. rowDel(row) {
  575. this.$confirm("确定将选择数据删除?", {
  576. confirmButtonText: "确定",
  577. cancelButtonText: "取消",
  578. type: "warning",
  579. }).then(() => {
  580. this.form.accItemsOpenblcList.splice(row.$index, 1);
  581. this.$message.success("操作成功!");
  582. });
  583. },
  584. forceAmt(val) {
  585. let amt = Number(val);
  586. return isNaN(amt) ? 0.0 : Number(amt.toFixed(2));
  587. },
  588. fmtAmt(val) {
  589. let amt = this.forceAmt(val);
  590. let S = amt.toFixed(2);
  591. return S == "0.00" ? "" : S;
  592. },
  593. amountChange(row, fieldName) {
  594. if (fieldName === "amountOpenDr" || fieldName === "amountOpenCr") {
  595. if (row.dc === "D") {
  596. this.$set(row, "amountOpenBlc", this.forceAmt(row.amountOpenDr) - this.forceAmt(row.amountOpenCr));
  597. this.$set(row, "amountBlc", this.forceAmt(row.amountOpenBlc) + this.forceAmt(row.amountDr) - this.forceAmt(row.amountCr));
  598. } else {
  599. this.$set(row, "amountOpenBlc", this.forceAmt(row.amountOpenCr) - this.forceAmt(row.amountOpenDr));
  600. this.$set(row, "amountBlc", this.forceAmt(row.amountOpenBlc) + this.forceAmt(row.amountCr) - this.forceAmt(row.amountDr));
  601. }
  602. }
  603. if (fieldName === "amountDr" || fieldName === "amountCr") {
  604. if (row.dc === "D") {
  605. this.$set(row, "amountBlc", this.forceAmt(row.amountOpenBlc) + this.forceAmt(row.amountDr) - this.forceAmt(row.amountCr));
  606. } else {
  607. this.$set(row, "amountBlc", this.forceAmt(row.amountOpenBlc) + this.forceAmt(row.amountCr) - this.forceAmt(row.amountDr));
  608. }
  609. }
  610. if (fieldName === "amountOpenDrUsd" || fieldName === "amountOpenCrUsd") {
  611. if (row.dc === "D") {
  612. this.$set(row, "amountOpenUsdBlc", this.forceAmt(row.amountOpenDrUsd) - this.forceAmt(row.amountOpenCrUsd));
  613. this.$set(row, "amountUsdBlc", this.forceAmt(row.amountOpenUsdBlc) + this.forceAmt(row.amountDrUsd) - this.forceAmt(row.amountCrUsd));
  614. } else {
  615. this.$set(row, "amountOpenUsdBlc", this.forceAmt(row.amountOpenCrUsd) - this.forceAmt(row.amountOpenDrUsd));
  616. this.$set(row, "amountUsdBlc", this.forceAmt(row.amountOpenUsdBlc) + this.forceAmt(row.amountCrUsd) - this.forceAmt(row.amountDrUsd));
  617. }
  618. }
  619. if (fieldName === "amountDrUsd" || fieldName === "amountCrUsd") {
  620. if (row.dc === "D") {
  621. this.$set(row, "amountUsdBlc", this.forceAmt(row.amountOpenUsdBlc) + this.forceAmt(row.amountDrUsd) - this.forceAmt(row.amountCrUsd));
  622. } else {
  623. this.$set(row, "amountUsdBlc", this.forceAmt(row.amountOpenUsdBlc) + this.forceAmt(row.amountCrUsd) - this.forceAmt(row.amountDrUsd));
  624. }
  625. }
  626. if (fieldName === "quantityOpenDr" || fieldName === "quantityOpenCr") {
  627. if (row.dc === "D") {
  628. this.$set(row, "quantityOpenBlc", this.forceAmt(row.quantityOpenDr) - this.forceAmt(row.quantityOpenCr));
  629. this.$set(row, "quantityBlc", this.forceAmt(row.quantityOpenBlc) + this.forceAmt(row.quantityDr) - this.forceAmt(row.quantityCr));
  630. } else {
  631. this.$set(row, "quantityOpenBlc", this.forceAmt(row.quantityOpenCr) - this.forceAmt(row.quantityOpenDr));
  632. this.$set(row, "quantityBlc", this.forceAmt(row.quantityOpenBlc) + this.forceAmt(row.quantityCr) - this.forceAmt(row.quantityDr));
  633. }
  634. }
  635. if (fieldName === "quantityDr" || fieldName === "quantityCr") {
  636. if (row.dc === "D") {
  637. this.$set(row, "quantityBlc", this.forceAmt(row.quantityOpenBlc) + this.forceAmt(row.quantityDr) - this.forceAmt(row.quantityCr));
  638. } else {
  639. this.$set(row, "quantityBlc", this.forceAmt(row.quantityOpenBlc) + this.forceAmt(row.quantityCr) - this.forceAmt(row.quantityDr));
  640. }
  641. }
  642. },
  643. // 下拉数据
  644. corpChange(value, name, row) {
  645. let bf = false;
  646. if (name == "shortName") {
  647. for (let item of this.corpData) {
  648. if (item.shortName == value) {
  649. this.$set(row, "corpId", item.id);
  650. this.$set(row, "corpCode", item.code);
  651. this.$set(row, "corpShortName", item.shortName);
  652. this.$set(row, "corpCnName", item.cnName);
  653. this.$set(row, "corpEnName", item.enName);
  654. bf = true;
  655. }
  656. }
  657. if (!bf) {
  658. this.$set(row, "corpId", 0);
  659. this.$set(row, "corpCode", "");
  660. this.$set(row, "corpShortName", "");
  661. this.$set(row, "corpCnName", "");
  662. this.$set(row, "corpEnName", "");
  663. }
  664. } else if (name == "emplName") {
  665. for (let item of this.emplData) {
  666. if (item.name == value) {
  667. this.$set(row, "emplId", item.id);
  668. this.$set(row, "emplName", item.name);
  669. bf = true;
  670. }
  671. }
  672. if (!bf) {
  673. this.$set(row, "emplId", 0);
  674. this.$set(row, "emplName", "");
  675. }
  676. } else if (name == "itemName") {
  677. for (let item of this.itemData) {
  678. if (item.cnName == value) {
  679. this.$set(row, "itemId", item.id);
  680. this.$set(row, "itemName", item.cnName);
  681. bf = true;
  682. }
  683. }
  684. if (!bf) {
  685. this.$set(row, "itemId", 0);
  686. this.$set(row, "itemName", "");
  687. }
  688. } else if (name == "deptName") {
  689. if (value && value.id) {
  690. this.$set(row, "deptId", value.id);
  691. this.$set(row, "deptName", value.title);
  692. }else{
  693. this.$set(row, "deptId", 0);
  694. this.$set(row, "deptName", "");
  695. }
  696. } else {
  697. this.$set(row, name, value);
  698. }
  699. },
  700. // 获取核算客户数据
  701. corpBcorpsListfun(shortName) {
  702. getBcorpslistByType(1, 10, { shortName }).then((res) => {
  703. this.corpData = res.data.data.records;
  704. });
  705. },
  706. // 获取部分数据
  707. deptDeptLazyTreefun() {
  708. getDeptTree().then((res) => {
  709. this.deptData = res.data.data;
  710. });
  711. },
  712. // 获取员工数据
  713. userPagelistfun(emplName) {
  714. selectEmpls(1, 10, { cname: emplName, whetherEmployedOrNot: 1 }).then((res) => {
  715. if (Array.isArray(res.data.data.records)) {
  716. res.data.data.records.forEach((item) => {
  717. item.name = item.cname;
  718. });
  719. }
  720. this.emplData = res.data.data.records;
  721. });
  722. },
  723. // 获取核算项目数据
  724. baccitemstypeListfun(cnName) {
  725. baccitemstypeList(1, 10, { cnName }).then((res) => {
  726. this.itemData = res.data.data.records;
  727. });
  728. },
  729. //自定义列保存
  730. async saveColumnTwo(ref, option, optionBack, code) {
  731. /**
  732. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  733. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  734. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  735. */
  736. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  737. if (inSave) {
  738. this.$message.success("保存成功");
  739. //关闭窗口
  740. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  741. }
  742. },
  743. //自定义列重置
  744. async resetColumnTwo(ref, option, optionBack, code) {
  745. this[option] = this[optionBack];
  746. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  747. if (inSave) {
  748. this.$message.success("重置成功");
  749. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  750. }
  751. },
  752. // 更改表格颜色
  753. headerClassName(tab) {
  754. //颜色间隔
  755. let back = "";
  756. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  757. if (tab.columnIndex % 2 === 0) {
  758. back = "back-one";
  759. } else if (tab.columnIndex % 2 === 1) {
  760. back = "back-two";
  761. }
  762. }
  763. return back;
  764. },
  765. },
  766. };
  767. </script>
  768. <style scoped>
  769. ::v-deep#out-table .back-one {
  770. /* background: #ecf5ff !important; */
  771. text-align: center;
  772. }
  773. ::v-deep#out-table .back-two {
  774. /* background: #ecf5ff !important; */
  775. text-align: center;
  776. }
  777. ::v-deep .avue-crud .el-input-number .el-input__inner {
  778. text-align: right;
  779. }
  780. </style>