stockInDetail.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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. <div class="cell clearfix">
  12. <el-input
  13. size="small"
  14. style="width: 400px;"
  15. class="filter-item"
  16. v-model.trim="searchKey"
  17. placeholder="单据编码/制单人/规格名称"
  18. />
  19. <el-button
  20. size="small"
  21. class="filter-item"
  22. type="primary"
  23. icon="el-icon-search"
  24. @click="search"
  25. >搜索</el-button
  26. >
  27. </div>
  28. <div class="cell clearfix">
  29. <label class="title"><span class="name">日期查询</span> : </label>
  30. <el-date-picker
  31. size="small"
  32. v-model="start_time"
  33. prefix-icon="el-icon-date"
  34. :editable="false"
  35. style="width: 196px;"
  36. type="date"
  37. placeholder="选择日期时间"
  38. align="right"
  39. format="yyyy-MM-dd"
  40. value-format="yyyy-MM-dd"
  41. @change="startTimeChange"
  42. ></el-date-picker>
  43. <span class="cellLine"> - </span>
  44. <el-date-picker
  45. size="small"
  46. v-model="end_time"
  47. prefix-icon="el-icon-date"
  48. :editable="false"
  49. style="width: 196px;"
  50. type="date"
  51. placeholder="选择日期时间"
  52. align="right"
  53. format="yyyy-MM-dd"
  54. value-format="yyyy-MM-dd"
  55. @change="endTimeChange"
  56. ></el-date-picker>
  57. </div>
  58. <div class="cell clearfix">
  59. <label class="title"><span class="name">单据类型</span> : </label>
  60. <el-select
  61. size="small"
  62. v-model="order_type"
  63. clearable
  64. placeholder="单据类型"
  65. @change="changeType"
  66. >
  67. <el-option
  68. v-for="item in orderTypeArr"
  69. :key="item.value"
  70. :label="item.label"
  71. :value="item.value"
  72. >
  73. </el-option>
  74. </el-select>
  75. </div>
  76. <div class="cell clearfix">
  77. <label class="title"><span class="name">其它</span> : </label>
  78. <el-select
  79. size="small"
  80. v-model="manufacturer_id"
  81. clearable
  82. placeholder="厂商"
  83. @change="changeManufacturer"
  84. >
  85. <el-option
  86. v-for="item in manufacturer"
  87. :key="item.id"
  88. :label="item.manufacturer_name"
  89. :value="item.id"
  90. >
  91. </el-option>
  92. </el-select>
  93. </div>
  94. <el-row :gutter="12" style="margin-top: 10px">
  95. <el-table
  96. :data="cancelStockDate"
  97. :class="signAndWeighBoxPatients"
  98. border
  99. highlight-current-row
  100. ref="multipleTable"
  101. @selection-change="select"
  102. :row-style="{ color: '#303133' }"
  103. :header-cell-style="{
  104. backgroundColor: 'rgb(245, 247, 250)',
  105. color: '#606266'
  106. }"
  107. >
  108. <el-table-column label="单据编号" align="center" width="200">
  109. <template slot-scope="scope">
  110. {{ scope.row.warehousing_order }}
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="商品类型" align="center">
  114. <template slot-scope="scope">
  115. {{ typeName(scope.row.good_type_id) }}
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="规格名称" align="center">
  119. <template slot-scope="scope">
  120. {{ specificationName(scope.row.good_id) }}
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="单据类型" align="center">
  124. <template slot-scope="scope">
  125. {{ getTypeName(scope.row) }}
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作时间" align="center">
  129. <template slot-scope="scope">
  130. {{ getTime(scope.row.Warehousing.warehousing_time) }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column label="制单人" align="center">
  134. <template slot-scope="scope">
  135. {{ getXuserName(scope.row.Warehousing.creater) }}
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="单价" align="center">
  139. <template slot-scope="scope">
  140. {{ scope.row.price }}
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="数量" align="center">
  144. <template slot-scope="scope">
  145. {{ scope.row.warehousing_count }}
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="总价" align="center">
  149. <template slot-scope="scope">
  150. <span v-if="scope.row.is_total == 0">{{
  151. getTotal(scope.row.price, scope.row.warehousing_count)
  152. }}</span>
  153. <span v-else>{{ scope.row.total }}</span>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. <el-pagination
  158. @size-change="handleSizeChange"
  159. @current-change="handleCurrentChange"
  160. :page-sizes="[10, 50, 100]"
  161. :page-size="10"
  162. background
  163. style="margin-top:20px;float: right"
  164. layout="total, sizes, prev, pager, next, jumper"
  165. :total="total"
  166. >
  167. </el-pagination>
  168. </el-row>
  169. </div>
  170. </template>
  171. <script>
  172. import { uParseTime } from "@/utils/tools";
  173. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  174. import {
  175. deleteCancelStock,
  176. GetAllConfig,
  177. getStockDetail,
  178. getPrintStockGood
  179. } from "@/api/stock";
  180. export default {
  181. name: "stockInDetail",
  182. created() {
  183. var nowDate = new Date();
  184. var nowYear = nowDate.getFullYear();
  185. var nowMonth = nowDate.getMonth() + 1;
  186. var nowDay = nowDate.getDate();
  187. this.end_time =
  188. nowYear +
  189. "-" +
  190. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  191. "-" +
  192. (nowDay < 10 ? "0" + nowDay : nowDay);
  193. nowDate.setMonth(nowDate.getMonth() - 1);
  194. nowYear = nowDate.getFullYear();
  195. nowMonth = nowDate.getMonth() + 1;
  196. nowDay = nowDate.getDate();
  197. this.start_time =
  198. nowYear +
  199. "-" +
  200. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  201. "-" +
  202. (nowDay < 10 ? "0" + nowDay : nowDay);
  203. this.GetCancelStock();
  204. this.GetConfigInfo();
  205. this.fetchAllAdminUsers();
  206. },
  207. data() {
  208. return {
  209. orderTypeArr: [
  210. { value: 1, label: "耗材入库单" },
  211. { value: 2, label: "其他入库单" }
  212. ],
  213. newDate: [{ name: "合计", num: "111111" }],
  214. searchKey: "",
  215. type: 1,
  216. page: 1,
  217. limit: 10,
  218. manufacturer_id: "",
  219. dealer_id: "",
  220. order_type: "",
  221. checked: false,
  222. total: 0,
  223. pageTotal: 0,
  224. pageSelect: 0,
  225. adminUserOptions: [],
  226. multipleSelection: [],
  227. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  228. start_time: "",
  229. cancelStockDate: [],
  230. end_time: "",
  231. goodType: [],
  232. goodInfo: [],
  233. manufacturer: [],
  234. selectedTableData: [],
  235. dealer: []
  236. };
  237. },
  238. methods: {
  239. changeType: function(val) {
  240. this.order_type = val;
  241. this.GetCancelStock();
  242. },
  243. changeManufacturer: function(val) {
  244. this.manufacturer_id = val;
  245. this.GetCancelStock();
  246. },
  247. changeDealer: function(val) {
  248. this.dealer_id = val;
  249. this.GetCancelStock();
  250. },
  251. getTypeName: function(row) {
  252. let name = "";
  253. if (row.type == 1) {
  254. name = "耗材入库单";
  255. } else if (row.type == 2) {
  256. name = "其他入库单";
  257. }
  258. return name;
  259. },
  260. typeName: function(good_type_id) {
  261. let name = "";
  262. for (let i = 0; i < this.goodType.length; i++) {
  263. if (this.goodType[i].id == good_type_id) {
  264. name = this.goodType[i].type_name;
  265. }
  266. }
  267. return name;
  268. },
  269. specificationName: function(good_info_id) {
  270. let name = "";
  271. for (let i = 0; i < this.goodInfo.length; i++) {
  272. if (this.goodInfo[i].id == good_info_id) {
  273. name = this.goodInfo[i].specification_name;
  274. }
  275. }
  276. return name;
  277. },
  278. search: function() {
  279. const Params = {
  280. page: this.page,
  281. limit: this.limit,
  282. start_time: this.start_time,
  283. end_time: this.end_time,
  284. type: this.type,
  285. keywords: this.searchKey
  286. };
  287. this.cancelStockDate = [];
  288. getStockDetail(Params).then(response => {
  289. if (response.data.state == 0) {
  290. this.$message.error(response.data.msg);
  291. return false;
  292. } else {
  293. this.total = response.data.data.total;
  294. for (let i = 0; i < response.data.data.list.length; i++) {
  295. var obj = response.data.data.list[i];
  296. obj["is_total"] = 0;
  297. this.cancelStockDate.push(obj);
  298. }
  299. this.cancelStockDate.push({
  300. warehousing_order: "合计",
  301. is_total: 1,
  302. total: response.data.data.total_price,
  303. Warehousing: {
  304. warehousing_time: 0
  305. }
  306. });
  307. }
  308. });
  309. },
  310. getTime: function(val) {
  311. if (val == 0) {
  312. return "";
  313. } else {
  314. return uParseTime(val, "{y}-{m}-{d}");
  315. }
  316. },
  317. AddNewOrder: function() {
  318. this.$router.push({
  319. name: "cancelStockOrderAdd",
  320. query: { type: this.type }
  321. });
  322. },
  323. GetCancelStock: function() {
  324. const Params = {
  325. page: this.page,
  326. limit: this.limit,
  327. start_time: this.start_time,
  328. end_time: this.end_time,
  329. type: this.type,
  330. manufacturer: this.manufacturer_id,
  331. order_type: this.order_type,
  332. dealer: this.dealer_id
  333. };
  334. this.cancelStockDate = [];
  335. getStockDetail(Params).then(response => {
  336. if (response.data.state == 0) {
  337. this.$message.error(response.data.msg);
  338. return false;
  339. } else {
  340. this.total = response.data.data.total;
  341. for (let i = 0; i < response.data.data.list.length; i++) {
  342. var obj = response.data.data.list[i];
  343. obj["is_total"] = 0;
  344. this.cancelStockDate.push(obj);
  345. }
  346. this.cancelStockDate.push({
  347. warehousing_order: "合计",
  348. is_total: 1,
  349. total: response.data.data.total_price,
  350. Warehousing: {
  351. warehousing_time: 0
  352. }
  353. });
  354. }
  355. });
  356. },
  357. getXuserName(id) {
  358. if (id <= 0) {
  359. return "";
  360. }
  361. var name = "";
  362. if (
  363. this.adminUserOptions == null ||
  364. typeof this.adminUserOptions.length === "undefined"
  365. ) {
  366. return name;
  367. }
  368. var leng = this.adminUserOptions.length;
  369. if (leng == 0) {
  370. return name;
  371. }
  372. for (let index = 0; index < leng; index++) {
  373. if (this.adminUserOptions[index].id == id) {
  374. name = this.adminUserOptions[index].name;
  375. break;
  376. }
  377. }
  378. return name;
  379. },
  380. fetchAllAdminUsers() {
  381. fetchAllAdminUsers().then(response => {
  382. console.log(response);
  383. if (response.data.state == 1) {
  384. this.adminUserOptions = response.data.data.users;
  385. var alen = this.adminUserOptions.length;
  386. for (let index = 0; index < alen; index++) {
  387. if (this.adminUserOptions[index].user_type == 2) {
  388. // this.doctorOptions.push(this.adminUserOptions[index]);
  389. }
  390. }
  391. }
  392. });
  393. },
  394. handleSelectionChange: function(val) {
  395. this.multipleSelection = val;
  396. },
  397. handleSizeChange(val) {
  398. this.limit = val;
  399. this.GetCancelStock();
  400. },
  401. handleCurrentChange(val) {
  402. this.page = val;
  403. this.GetCancelStock();
  404. },
  405. startTimeChange(val) {
  406. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  407. if (time > 0) {
  408. this.$message.error("结束时间不能小于开始时间");
  409. this.start_time = "";
  410. } else {
  411. this.GetCancelStock();
  412. }
  413. },
  414. endTimeChange(val) {
  415. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  416. if (time < 0) {
  417. this.$message.error("结束时间不能小于开始时间");
  418. this.end_time = "";
  419. } else {
  420. this.GetCancelStock();
  421. }
  422. },
  423. getTimestamp(time) {
  424. // 把时间日期转成时间戳
  425. return new Date(time).getTime() / 1000;
  426. },
  427. calculate: function(val) {
  428. return Math.round(parseFloat(val) * 100) / 100;
  429. },
  430. GetConfigInfo: function() {
  431. GetAllConfig().then(response => {
  432. if (response.data.state == 0) {
  433. this.$message.error(response.data.msg);
  434. return false;
  435. } else {
  436. this.manufacturer = response.data.data.manufacturer;
  437. this.dealer = response.data.data.dealer;
  438. this.goodInfo = response.data.data.goodInfo;
  439. this.goodType = response.data.data.goodType;
  440. }
  441. });
  442. },
  443. getManufactuerName: function(manufacturer_id) {
  444. for (let i = 0; i < this.manufacturer.length; i++) {
  445. if (this.manufacturer[i].id == manufacturer_id) {
  446. return this.manufacturer[i].manufacturer_name;
  447. }
  448. }
  449. },
  450. getDealerName: function(dealer_id) {
  451. for (let i = 0; i < this.dealer.length; i++) {
  452. if (this.dealer[i].id == dealer_id) {
  453. return this.dealer[i].dealer_name;
  454. }
  455. }
  456. },
  457. handleEdit: function(index, row) {
  458. this.$router.push({
  459. name: "cancelStockDetail",
  460. query: { id: row.id, type: this.type }
  461. });
  462. },
  463. handleDelete: function(index, row) {
  464. const ids = [];
  465. ids.push(row.id);
  466. const idStr = ids.join(",");
  467. const params = {
  468. ids: idStr
  469. };
  470. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  471. confirmButtonText: "确定",
  472. cancelButtonText: "取消",
  473. type: "warning"
  474. })
  475. .then(() => {
  476. deleteCancelStock(params).then(response => {
  477. if (response.data.state == 0) {
  478. this.$message.error(response.data.msg);
  479. return false;
  480. } else {
  481. this.$notify({
  482. title: "成功",
  483. message: "删除成功",
  484. type: "success",
  485. duration: 2000
  486. });
  487. for (let i = 0; i < ids.length; i++) {
  488. for (let y = 0; y < this.cancelStockDate.length; y++) {
  489. if (ids[i] == this.cancelStockDate[y].id) {
  490. this.cancelStockDate.splice(y, 1);
  491. }
  492. }
  493. }
  494. }
  495. });
  496. })
  497. .catch(() => {});
  498. },
  499. changeAllSelected: function(val) {
  500. if (val) {
  501. this.$refs.multipleTable.toggleAllSelection();
  502. } else {
  503. this.$refs.multipleTable.clearSelection();
  504. }
  505. },
  506. select(selection) {
  507. this.selectedTableData = selection;
  508. },
  509. batchDelete() {
  510. if (this.selectedTableData.length <= 0) {
  511. this.$message.error("请选择要删除的记录");
  512. return;
  513. }
  514. const ids = [];
  515. for (let i = 0; i < this.selectedTableData.length; i++) {
  516. ids.push(this.selectedTableData[i].id);
  517. }
  518. const idStr = ids.join(",");
  519. const params = {
  520. ids: idStr
  521. };
  522. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  523. confirmButtonText: "确定",
  524. cancelButtonText: "取消",
  525. type: "warning"
  526. })
  527. .then(() => {
  528. deleteCancelStock(params).then(response => {
  529. if (response.data.state == 0) {
  530. this.$message.error(response.data.msg);
  531. return false;
  532. } else {
  533. this.$notify({
  534. title: "成功",
  535. message: "删除成功",
  536. type: "success",
  537. duration: 2000
  538. });
  539. for (let i = 0; i < ids.length; i++) {
  540. for (let y = 0; y < this.cancelStockDate.length; y++) {
  541. if (ids[i] == this.cancelStockDate[y].id) {
  542. this.cancelStockDate.splice(y, 1);
  543. }
  544. }
  545. }
  546. }
  547. });
  548. })
  549. .catch(() => {});
  550. },
  551. getTotal: function(price, total) {
  552. var m = 0,
  553. r1,
  554. r2;
  555. var s1 = price.toString();
  556. var s2 = total.toString();
  557. try {
  558. m += s1.split(".")[1].length;
  559. } catch (e) {}
  560. try {
  561. } catch (e) {
  562. m += s2.split(".")[1].length;
  563. }
  564. r1 = Number(price.toString().replace(".", ""));
  565. r2 = Number(total.toString().replace(".", ""));
  566. return (r1 * r2) / Math.pow(10, m);
  567. },
  568. PrintAction: function() {
  569. this.$router.push({
  570. path: "/stock/print",
  571. query: {
  572. type: 1,
  573. start_time: this.start_time,
  574. end_time: this.end_time
  575. }
  576. });
  577. }
  578. }
  579. };
  580. </script>
  581. <style rel="stylesheet/css" lang="scss" scoped>
  582. .information {
  583. border: 1px #dcdfe6 solid;
  584. padding: 30px 20px 30px 20px;
  585. .border {
  586. border-bottom: 1px #dcdfe6 solid;
  587. margin: 0px 0 20px 0;
  588. }
  589. }
  590. .edit_separater {
  591. border-top: 1px solid rgb(233, 233, 233);
  592. margin-top: 15px;
  593. margin-bottom: 15px;
  594. }
  595. </style>
  596. <style>
  597. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  598. font-size: 12px;
  599. }
  600. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  601. background: #6fb5fa;
  602. }
  603. .count {
  604. color: #bd2c00;
  605. }
  606. .el-table td,
  607. .el-table th.is-leaf,
  608. .el-table--border,
  609. .el-table--group {
  610. border-color: #d0d3da;
  611. }
  612. .el-table--border::after,
  613. .el-table--group::after,
  614. .el-table::before {
  615. background-color: #d0d3da;
  616. }
  617. </style>