stockOutDetail.vue 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. <template>
  2. <div>
  3. <el-button
  4. style="float: right"
  5. size="small"
  6. icon="el-icon-printer"
  7. @click="PrintAction"
  8. type="primary"
  9. >打印
  10. </el-button>
  11. <el-button
  12. style="float: right;margin-right:10px"
  13. size="small"
  14. @click="exportList"
  15. type="primary"
  16. >导出
  17. </el-button>
  18. <div class="cell clearfix">
  19. <el-input
  20. size="small"
  21. style="width: 400px;"
  22. class="filter-item"
  23. v-model.trim="searchKey"
  24. placeholder="单据编码/制单人/规格名称"
  25. />
  26. <el-button
  27. size="small"
  28. class="filter-item"
  29. type="primary"
  30. icon="el-icon-search"
  31. @click="search"
  32. >搜索</el-button
  33. >
  34. </div>
  35. <div class="cell clearfix">
  36. <label class="title"><span class="name">日期查询</span> : </label>
  37. <el-date-picker
  38. size="small"
  39. v-model="start_time"
  40. prefix-icon="el-icon-date"
  41. :editable="false"
  42. style="width: 196px;"
  43. type="date"
  44. placeholder="选择日期时间"
  45. align="right"
  46. format="yyyy-MM-dd"
  47. value-format="yyyy-MM-dd"
  48. @change="startTimeChange"
  49. ></el-date-picker>
  50. <span class="cellLine"> - </span>
  51. <el-date-picker
  52. size="small"
  53. v-model="end_time"
  54. prefix-icon="el-icon-date"
  55. :editable="false"
  56. style="width: 196px;"
  57. type="date"
  58. placeholder="选择日期时间"
  59. align="right"
  60. format="yyyy-MM-dd"
  61. value-format="yyyy-MM-dd"
  62. @change="endTimeChange"
  63. ></el-date-picker>
  64. </div>
  65. <!-- <div class="cell clearfix">
  66. <label class="title"><span class="name">单据类型</span> : </label>
  67. <el-select
  68. size="small"
  69. v-model="order_type"
  70. clearable
  71. placeholder="单据类型"
  72. @change="changeType"
  73. >
  74. <el-option
  75. v-for="item in orderTypeArr"
  76. :key="item.value"
  77. :label="item.label"
  78. :value="item.value"
  79. >
  80. </el-option>
  81. </el-select>
  82. </div> -->
  83. <!-- <div class="cell clearfix">
  84. <label class="title"><span class="name">其它</span> : </label>
  85. <el-select
  86. size="small"
  87. v-model="manufacturer_id"
  88. clearable
  89. placeholder="厂商"
  90. @change="changeManufacturer"
  91. >
  92. <el-option
  93. v-for="item in manufacturer"
  94. :key="item.id"
  95. :label="item.manufacturer_name"
  96. :value="item.id"
  97. >
  98. </el-option>
  99. </el-select>
  100. </div> -->
  101. <el-row :gutter="12" style="margin-top: 10px">
  102. <el-table
  103. :data="cancelStockDate"
  104. :class="signAndWeighBoxPatients"
  105. border
  106. highlight-current-row
  107. ref="multipleTable"
  108. @selection-change="select"
  109. :row-style="{ color: '#303133' }"
  110. :header-cell-style="{
  111. backgroundColor: 'rgb(245, 247, 250)',
  112. color: '#606266'
  113. }"
  114. >
  115. <el-table-column label="单据编号" align="center" width="200">
  116. <template slot-scope="scope">
  117. {{ scope.row.warehouse_out_order_number }}
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="耗材类型" align="center">
  121. <template slot-scope="scope">
  122. {{ typeName(scope.row.good_type_id) }}
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="耗材名称" align="center">
  126. <template slot-scope="scope">
  127. {{ typeNameOne(scope.row.good_id) }}
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="规格型号" align="center">
  131. <template slot-scope="scope">
  132. {{ specificationName(scope.row.good_id) }}
  133. </template>
  134. </el-table-column>
  135. <!-- <el-table-column label="单据类型" align="center">
  136. <template slot-scope="scope">
  137. {{ getTypeName(scope.row) }}
  138. </template>
  139. </el-table-column> -->
  140. <el-table-column label="操作时间" align="center">
  141. <template slot-scope="scope">
  142. {{ getTime(scope.row.WarehouseOut.warehouse_out_time) }}
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="制单人" align="center">
  146. <template slot-scope="scope">
  147. {{ getXuserName(scope.row.WarehouseOut.creater) }}
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="出货价" align="center">
  151. <template slot-scope="scope">
  152. {{ scope.row.price }}
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="数量" align="center">
  156. <template slot-scope="scope">
  157. <span v-if="orgId!=9583">{{ scope.row.count }}</span>
  158. <span v-if="orgId ==9583">{{getStockCount(scope.row.good_id) }}</span>
  159. </template>
  160. </el-table-column>
  161. <el-table-column label="总价" align="center">
  162. <template slot-scope="scope">
  163. <span v-if="scope.row.is_total == 0">{{
  164. getTotal(scope.row.price, scope.row.count)
  165. }}</span>
  166. <span v-else>{{ scope.row.total }}</span>
  167. </template>
  168. </el-table-column>
  169. </el-table>
  170. <el-pagination
  171. @size-change="handleSizeChange"
  172. @current-change="handleCurrentChange"
  173. :page-sizes="[10, 50, 100,1000,1500]"
  174. :page-size="10"
  175. background
  176. style="margin-top:20px;float: right"
  177. layout="total, sizes, prev, pager, next, jumper"
  178. :total="total"
  179. >
  180. </el-pagination>
  181. </el-row>
  182. </div>
  183. </template>
  184. <script>
  185. import { uParseTime } from "@/utils/tools";
  186. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  187. import { deleteCancelStock, GetAllConfig, getStockDetail,getPrintStockGood,getGoodInfoList } from "@/api/stock";
  188. export default {
  189. name: "stockOutDetail",
  190. created() {
  191. var nowDate = new Date();
  192. var nowYear = nowDate.getFullYear();
  193. var nowMonth = nowDate.getMonth() + 1;
  194. var nowDay = nowDate.getDate();
  195. this.end_time =
  196. nowYear +
  197. "-" +
  198. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  199. "-" +
  200. (nowDay < 10 ? "0" + nowDay : nowDay);
  201. nowDate.setMonth(nowDate.getMonth() - 1);
  202. nowYear = nowDate.getFullYear();
  203. nowMonth = nowDate.getMonth() + 1;
  204. nowDay = nowDate.getDate();
  205. this.start_time =
  206. nowYear +
  207. "-" +
  208. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  209. "-" +
  210. (nowDay < 10 ? "0" + nowDay : nowDay);
  211. this.GetCancelStock();
  212. this.GetConfigInfo();
  213. this.fetchAllAdminUsers();
  214. this.goodUnit = this.$store.getters.good_unit
  215. this.getPrintStockGood()
  216. this.getList()
  217. var org_id = this.$store.getters.xt_user.org.id
  218. this.orgId = org_id
  219. console.log("机构信息",org_id)
  220. },
  221. data() {
  222. return {
  223. orderTypeArr: [
  224. { value: 1, label: "耗材入库单" },
  225. { value: 2, label: "其他入库单" }
  226. ],
  227. manufacturer_id: "",
  228. dealer_id: "",
  229. order_type: "",
  230. searchKey: "",
  231. type: 2,
  232. page: 1,
  233. limit: 10,
  234. checked: false,
  235. total: 0,
  236. pageTotal: 0,
  237. pageSelect: 0,
  238. adminUserOptions: [],
  239. multipleSelection: [],
  240. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  241. start_time: "",
  242. cancelStockDate: [],
  243. end_time: "",
  244. goodType: [],
  245. goodInfo: [],
  246. manufacturer: [],
  247. selectedTableData: [],
  248. dealer: [],
  249. goodUnit:[],
  250. tableList:[],
  251. stockTotal:[],
  252. goodInfoData:[],
  253. orgId:"",
  254. };
  255. },
  256. methods: {
  257. changeType: function(val) {
  258. this.order_type = val;
  259. this.GetCancelStock();
  260. this.getPrintStockGood()
  261. },
  262. changeManufacturer: function(val) {
  263. this.manufacturer_id = val;
  264. this.GetCancelStock();
  265. this.getPrintStockGood()
  266. },
  267. getTypeName: function(row) {
  268. let name = "";
  269. const name2 = "";
  270. if (row.type == 1) {
  271. name = "耗材出库单";
  272. } else if (row.type == 2) {
  273. name = "其他出库单";
  274. }
  275. return name;
  276. },
  277. specificationName: function(good_info_id) {
  278. let name = "";
  279. for (let i = 0; i < this.goodInfo.length; i++) {
  280. if (this.goodInfo[i].id == good_info_id) {
  281. name = this.goodInfo[i].specification_name;
  282. }
  283. }
  284. return name;
  285. },
  286. typeName: function(good_type_id) {
  287. let name = "";
  288. for (let i = 0; i < this.goodType.length; i++) {
  289. if (this.goodType[i].id == good_type_id) {
  290. name = this.goodType[i].type_name;
  291. }
  292. }
  293. return name;
  294. },
  295. typeNameOne:function(good_id){
  296. let name = "";
  297. for (let i = 0; i < this.goodInfo.length; i++) {
  298. if (this.goodInfo[i].id == good_id) {
  299. name = this.goodInfo[i].good_name;
  300. }
  301. }
  302. return name;
  303. },
  304. search: function() {
  305. const Params = {
  306. page: this.page,
  307. limit: this.limit,
  308. start_time: this.start_time,
  309. end_time: this.end_time,
  310. type: this.type,
  311. keywords: this.searchKey
  312. };
  313. this.cancelStockDate = [];
  314. getStockDetail(Params).then(response => {
  315. if (response.data.state == 0) {
  316. this.$message.error(response.data.msg);
  317. return false;
  318. } else {
  319. this.total = response.data.data.total;
  320. for (let i = 0; i < response.data.data.list.length; i++) {
  321. var obj = response.data.data.list[i];
  322. obj["is_total"] = 0;
  323. this.cancelStockDate.push(obj);
  324. }
  325. this.cancelStockDate.push({
  326. warehouse_out_order_number: "合计",
  327. is_total: 1,
  328. total: response.data.data.total_price,
  329. WarehouseOut: {
  330. warehouse_out_time: 0
  331. }
  332. });
  333. }
  334. });
  335. },
  336. AddNewOrder: function() {
  337. this.$router.push({
  338. name: "cancelStockOrderAdd",
  339. query: { type: this.type }
  340. });
  341. },
  342. GetCancelStock: function() {
  343. const Params = {
  344. page: this.page,
  345. limit: this.limit,
  346. start_time: this.start_time,
  347. end_time: this.end_time,
  348. type: this.type,
  349. manufacturer: this.manufacturer_id,
  350. order_type: this.order_type,
  351. dealer: this.dealer_id
  352. };
  353. console.log("parasm334444444",Params)
  354. this.cancelStockDate = [];
  355. getStockDetail(Params).then(response => {
  356. if (response.data.state == 0) {
  357. this.$message.error(response.data.msg);
  358. return false;
  359. } else {
  360. this.total = response.data.data.total;
  361. console.log("详情23233323",response.data.data.list)
  362. for (let i = 0; i < response.data.data.list.length; i++) {
  363. var obj = response.data.data.list[i];
  364. obj["is_total"] = 0;
  365. this.cancelStockDate.push(obj);
  366. }
  367. this.cancelStockDate.push({
  368. warehouse_out_order_number: "合计",
  369. is_total: 1,
  370. total: response.data.data.total_price,
  371. WarehouseOut: {
  372. warehouse_out_time: 0
  373. }
  374. });
  375. }
  376. });
  377. },
  378. getXuserName(id) {
  379. if (id <= 0) {
  380. return "";
  381. }
  382. var name = "";
  383. if (
  384. this.adminUserOptions == null ||
  385. typeof this.adminUserOptions.length === "undefined"
  386. ) {
  387. return name;
  388. }
  389. var leng = this.adminUserOptions.length;
  390. if (leng == 0) {
  391. return name;
  392. }
  393. for (let index = 0; index < leng; index++) {
  394. if (this.adminUserOptions[index].id == id) {
  395. name = this.adminUserOptions[index].name;
  396. break;
  397. }
  398. }
  399. return name;
  400. },
  401. fetchAllAdminUsers() {
  402. fetchAllAdminUsers().then(response => {
  403. console.log(response);
  404. if (response.data.state == 1) {
  405. this.adminUserOptions = response.data.data.users;
  406. var alen = this.adminUserOptions.length;
  407. for (let index = 0; index < alen; index++) {
  408. if (this.adminUserOptions[index].user_type == 2) {
  409. // this.doctorOptions.push(this.adminUserOptions[index]);
  410. }
  411. }
  412. }
  413. });
  414. },
  415. handleSelectionChange: function(val) {
  416. this.multipleSelection = val;
  417. },
  418. handleSizeChange(val) {
  419. this.limit = val;
  420. this.GetCancelStock();
  421. this.getPrintStockGood()
  422. },
  423. handleCurrentChange(val) {
  424. this.page = val;
  425. this.GetCancelStock();
  426. this.getPrintStockGood()
  427. },
  428. startTimeChange(val) {
  429. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  430. if (time > 0) {
  431. this.$message.error("结束时间不能小于开始时间");
  432. this.start_time = "";
  433. } else {
  434. this.GetCancelStock();
  435. this.getPrintStockGood()
  436. }
  437. },
  438. endTimeChange(val) {
  439. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  440. if (time < 0) {
  441. this.$message.error("结束时间不能小于开始时间");
  442. this.end_time = "";
  443. } else {
  444. this.GetCancelStock();
  445. this.getPrintStockGood()
  446. }
  447. },
  448. getTimestamp(time) {
  449. // 把时间日期转成时间戳
  450. return new Date(time).getTime() / 1000;
  451. },
  452. calculate: function(val) {
  453. return Math.round(parseFloat(val) * 100) / 100;
  454. },
  455. GetConfigInfo: function() {
  456. GetAllConfig().then(response => {
  457. if (response.data.state == 0) {
  458. this.$message.error(response.data.msg);
  459. return false;
  460. } else {
  461. this.manufacturer = response.data.data.manufacturer;
  462. this.dealer = response.data.data.dealer;
  463. this.goodInfo = response.data.data.goodInfo;
  464. this.goodType = response.data.data.goodType;
  465. }
  466. });
  467. },
  468. getManufactuerName: function(manufacturer_id) {
  469. for (let i = 0; i < this.manufacturer.length; i++) {
  470. if (this.manufacturer[i].id == manufacturer_id) {
  471. return this.manufacturer[i].manufacturer_name;
  472. }
  473. }
  474. },
  475. getDealerName: function(dealer_id) {
  476. for (let i = 0; i < this.dealer.length; i++) {
  477. if (this.dealer[i].id == dealer_id) {
  478. return this.dealer[i].dealer_name;
  479. }
  480. }
  481. },
  482. handleEdit: function(index, row) {
  483. this.$router.push({
  484. name: "cancelStockDetail",
  485. query: { id: row.id, type: this.type }
  486. });
  487. },
  488. handleDelete: function(index, row) {
  489. const ids = [];
  490. ids.push(row.id);
  491. const idStr = ids.join(",");
  492. const params = {
  493. ids: idStr
  494. };
  495. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  496. confirmButtonText: "确定",
  497. cancelButtonText: "取消",
  498. type: "warning"
  499. })
  500. .then(() => {
  501. deleteCancelStock(params).then(response => {
  502. if (response.data.state == 0) {
  503. this.$message.error(response.data.msg);
  504. return false;
  505. } else {
  506. this.$notify({
  507. title: "成功",
  508. message: "删除成功",
  509. type: "success",
  510. duration: 2000
  511. });
  512. for (let i = 0; i < ids.length; i++) {
  513. for (let y = 0; y < this.cancelStockDate.length; y++) {
  514. if (ids[i] == this.cancelStockDate[y].id) {
  515. this.cancelStockDate.splice(y, 1);
  516. }
  517. }
  518. }
  519. }
  520. });
  521. })
  522. .catch(() => {});
  523. },
  524. changeAllSelected: function(val) {
  525. if (val) {
  526. this.$refs.multipleTable.toggleAllSelection();
  527. } else {
  528. this.$refs.multipleTable.clearSelection();
  529. }
  530. },
  531. select(selection) {
  532. this.selectedTableData = selection;
  533. },
  534. batchDelete() {
  535. if (this.selectedTableData.length <= 0) {
  536. this.$message.error("请选择要删除的记录");
  537. return;
  538. }
  539. const ids = [];
  540. for (let i = 0; i < this.selectedTableData.length; i++) {
  541. ids.push(this.selectedTableData[i].id);
  542. }
  543. const idStr = ids.join(",");
  544. const params = {
  545. ids: idStr
  546. };
  547. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  548. confirmButtonText: "确定",
  549. cancelButtonText: "取消",
  550. type: "warning"
  551. })
  552. .then(() => {
  553. deleteCancelStock(params).then(response => {
  554. if (response.data.state == 0) {
  555. this.$message.error(response.data.msg);
  556. return false;
  557. } else {
  558. this.$notify({
  559. title: "成功",
  560. message: "删除成功",
  561. type: "success",
  562. duration: 2000
  563. });
  564. for (let i = 0; i < ids.length; i++) {
  565. for (let y = 0; y < this.cancelStockDate.length; y++) {
  566. if (ids[i] == this.cancelStockDate[y].id) {
  567. this.cancelStockDate.splice(y, 1);
  568. }
  569. }
  570. }
  571. }
  572. });
  573. })
  574. .catch(() => {});
  575. },
  576. getTotal: function(price, total) {
  577. var m = 0,
  578. r1,
  579. r2;
  580. var s1 = price.toString();
  581. var s2 = total.toString();
  582. try {
  583. m += s1.split(".")[1].length;
  584. } catch (e) {}
  585. try {
  586. } catch (e) {
  587. m += s2.split(".")[1].length;
  588. }
  589. r1 = Number(price.toString().replace(".", ""));
  590. r2 = Number(total.toString().replace(".", ""));
  591. return (r1 * r2) / Math.pow(10, m);
  592. },
  593. getTime: function(val) {
  594. if (val == 0) {
  595. return "";
  596. } else {
  597. return uParseTime(val, "{y}-{m}-{d}");
  598. }
  599. },
  600. PrintAction: function() {
  601. this.$router.push({
  602. path: "/stock/print",
  603. query: {
  604. type: 3,
  605. start_time: this.start_time,
  606. end_time: this.end_time
  607. }
  608. });
  609. },
  610. getPrintStockGood(){
  611. const params = {
  612. start_time:this.start_time,
  613. end_time:this.end_time,
  614. type:3,
  615. }
  616. console.log("params",params)
  617. getPrintStockGood(params).then(response=>{
  618. if(response.data.state == 1){
  619. var stockTotal = response.data.data.stockTotal
  620. console.log("stockTotal",stockTotal)
  621. this.stockTotal = stockTotal
  622. var list = response.data.data.list
  623. console.log("导出数据",list)
  624. this.tableList = []
  625. for(let i=0;i<list.length;i++){
  626. if (list[i].query_warehouseout_info.length > 0) {
  627. this.tableList.push(list[i])
  628. }
  629. }
  630. console.log("耗材出库表格数据",this.tableList)
  631. }
  632. })
  633. },
  634. calCount(stock) {
  635. let total = 0
  636. var array = []
  637. array = stock.query_warehousing_info
  638. for (let i = 0; i < array.length; i++) {
  639. total = total + array[i].warehousing_count
  640. }
  641. return total
  642. },
  643. calTotal(stock) {
  644. var array = []
  645. array = stock.query_warehousing_info
  646. let total_price = 0.0
  647. for (let i = 0; i < array.length; i++) {
  648. total_price = total_price + array[i].warehousing_count * array[i].price
  649. }
  650. return Math.floor(total_price * 100) / 100
  651. },
  652. calTotalPrice() {
  653. var amountPrice = 0
  654. for (let i = 0; i < this.tableList.length; i++) {
  655. var obj = this.tableList[i]
  656. var len = 0
  657. len = obj.query_warehouseout_info.length
  658. let total_price = 0.0
  659. for (let a = 0; a < len; a++) {
  660. total_price = total_price + obj.query_warehouseout_info[a].total_price
  661. }
  662. amountPrice = amountPrice + Math.floor(total_price* 100) / 100
  663. }
  664. return Math.floor(amountPrice* 100) / 100
  665. },
  666. getStockCount(id){
  667. var count = ""
  668. for(let i=0;i<this.stockTotal.length;i++){
  669. if(id == this.stockTotal[i].good_id){
  670. count = this.stockTotal[i].count
  671. }
  672. }
  673. return count
  674. },
  675. getTotal: function(price, total) {
  676. var m = 0, r1, r2
  677. var s1 = price.toString()
  678. var s2 = total.toString()
  679. try {
  680. m += s1.split('.')[1].length
  681. } catch (e) {
  682. }
  683. try {
  684. } catch (e) {
  685. m += s2.split('.')[1].length
  686. }
  687. r1 = Number(price.toString().replace('.', ''))
  688. r2 = Number(total.toString().replace('.', ''))
  689. return r1 * r2 / Math.pow(10, m)
  690. },
  691. unique(arr) {
  692. const res = new Map();
  693. return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1));
  694. },
  695. getList() {
  696. let params = {
  697. page: 1,
  698. limit: 1000,
  699. keyword: "",
  700. is_use:"",
  701. good_kind:"",
  702. is_charge: "",
  703. is_mark:"",
  704. manufacturer:"",
  705. }
  706. getGoodInfoList(params).then(response => {
  707. if (response.data.state == 0) {
  708. this.$message.error(response.data.msg)
  709. return false
  710. } else {
  711. this.goodInfoData = []
  712. for (let i = 0; i < response.data.data.list.length; i++) {
  713. this.goodInfoData.push(response.data.data.list[i])
  714. }
  715. }
  716. })
  717. },
  718. exportList(){
  719. for(let i=0;i<this.tableList.length;i++){
  720. for(let j=0;j<this.goodInfoData.length;j++){
  721. if(this.tableList[i].id === this.goodInfoData[j].id){
  722. this.tableList[i].buy_price = this.goodInfoData[j].buy_price
  723. }
  724. }
  725. }
  726. console.log('合并后',this.tableList)
  727. var obj = {index:"合计",total:0}
  728. obj.total = this.getTotalPrice()
  729. for(let i=0;i<this.tableList.length;i++){
  730. this.tableList[i].index = i+1
  731. this.tableList[i].min_unit = this.getUnit(this.tableList[i].good_unit)
  732. this.tableList[i].count = this.getStockCount(this.tableList[i].id)
  733. this.tableList[i].total = (this.getStockCount(this.tableList[i].id) * this.tableList[i].buy_price).toFixed(2)
  734. this.tableList[i].remark = this.tableList[i].query_warehouseout_info[0].remark
  735. this.tableList[i].packing_unit = this.tableList[i].packing_unit
  736. }
  737. var arr = this.unique(this.tableList)
  738. this.tableList = arr
  739. this.tableList.push(obj)
  740. import('@/vendor/Export2Excel').then(excel => {
  741. const tHeader = ['序号','耗材名称', '规格型号', '单位','数量','出货价','总价','备注']
  742. const filterVal = ['index','good_name', 'specification_name', 'packing_unit','count','buy_price','total','remark']
  743. const data = this.formatJson(filterVal, this.tableList)
  744. console.log("data",data)
  745. excel.export_json_to_excel({
  746. header: tHeader,
  747. data,
  748. filename: '耗材出库明细'
  749. })
  750. this.downloadLoading = false
  751. })
  752. },
  753. formatJson(filterVal, jsonData) {
  754. return jsonData.map(v => filterVal.map(j => v[j]));
  755. },
  756. getUnit(id){
  757. var name = ""
  758. for(let i=0;i<this.goodUnit.length;i++){
  759. if(this.goodUnit[i].id == id){
  760. name = this.goodUnit[i].name
  761. }
  762. }
  763. return name
  764. },
  765. getTotalPrice(){
  766. var total_price = 0
  767. for(let i=0;i<this.tableList.length;i++){
  768. total_price += this.getStockCount(this.tableList[i].id) * this.tableList[i].retail_price
  769. }
  770. return total_price
  771. },
  772. }
  773. };
  774. </script>
  775. <style rel="stylesheet/css" lang="scss" scoped>
  776. .information {
  777. border: 1px #dcdfe6 solid;
  778. padding: 30px 20px 30px 20px;
  779. .border {
  780. border-bottom: 1px #dcdfe6 solid;
  781. margin: 0px 0 20px 0;
  782. }
  783. }
  784. .edit_separater {
  785. border-top: 1px solid rgb(233, 233, 233);
  786. margin-top: 15px;
  787. margin-bottom: 15px;
  788. }
  789. </style>
  790. <style>
  791. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  792. font-size: 12px;
  793. }
  794. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  795. background: #6fb5fa;
  796. }
  797. .count {
  798. color: #bd2c00;
  799. }
  800. .el-table td,
  801. .el-table th.is-leaf,
  802. .el-table--border,
  803. .el-table--group {
  804. border-color: #d0d3da;
  805. }
  806. .el-table--border::after,
  807. .el-table--group::after,
  808. .el-table::before {
  809. background-color: #d0d3da;
  810. }
  811. </style>