stockOutOrder.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-button
  6. size="small"
  7. @click="AddNewOrder"
  8. class="filter-item"
  9. style="float:right;"
  10. type="primary"
  11. icon="el-icon-circle-plus-outline"
  12. >新增</el-button
  13. >
  14. </div>
  15. <div class="app-container">
  16. <div class="cell clearfix">
  17. <el-input
  18. size="small"
  19. style="width: 400px;"
  20. class="filter-item"
  21. v-model.trim="searchKey"
  22. placeholder="单据编码/制单人/厂商"
  23. />
  24. <el-button
  25. size="small"
  26. class="filter-item"
  27. type="primary"
  28. icon="el-icon-search"
  29. @click="search"
  30. >搜索</el-button
  31. >
  32. </div>
  33. <div class="cell clearfix">
  34. <label class="title"><span class="name">出库时间</span> : </label>
  35. <el-date-picker
  36. size="small"
  37. v-model="start_time"
  38. prefix-icon="el-icon-date"
  39. :editable="false"
  40. style="width: 196px;"
  41. type="date"
  42. placeholder="选择日期时间"
  43. align="right"
  44. format="yyyy-MM-dd"
  45. value-format="yyyy-MM-dd"
  46. @change="startTimeChange"
  47. ></el-date-picker>
  48. <span class="cellLine"> - </span>
  49. <el-date-picker
  50. size="small"
  51. v-model="end_time"
  52. prefix-icon="el-icon-date"
  53. :editable="false"
  54. style="width: 196px;"
  55. type="date"
  56. placeholder="选择日期时间"
  57. align="right"
  58. format="yyyy-MM-dd"
  59. value-format="yyyy-MM-dd"
  60. @change="endTimeChange"
  61. ></el-date-picker>
  62. </div>
  63. <div class="cell clearfix">
  64. <el-checkbox
  65. style="width: 70px"
  66. v-model="checked"
  67. @change="changeAllSelected"
  68. >全选</el-checkbox
  69. >
  70. <el-button size="small" icon="el-icon-delete" @click="batchDelete"
  71. >删除</el-button
  72. >
  73. </div>
  74. <el-table
  75. :data="warehouseOutDate"
  76. :class="signAndWeighBoxPatients"
  77. style="width: 100%"
  78. border
  79. highlight-current-row
  80. ref="multipleTable"
  81. @selection-change="select"
  82. :row-style="{ color: '#303133' }"
  83. :header-cell-style="{
  84. backgroundColor: 'rgb(245, 247, 250)',
  85. color: '#606266'
  86. }"
  87. >
  88. <el-table-column type="selection" width="55"> </el-table-column>
  89. <el-table-column label="单据日期" align="center">
  90. <template slot-scope="scope">
  91. {{ scope.row.warehouse_out_time | parseTime("{y}-{m}-{d}") }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="单据编号" align="center">
  95. <template slot-scope="scope">
  96. {{ scope.row.warehouse_out_order_number }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="制单人" align="center">
  100. <template slot-scope="scope">
  101. {{ getXuserName(scope.row.creater) }}
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="厂家" align="center">
  105. <template slot-scope="scope">
  106. {{ getManufactuerName(scope.row.manufacturer) }}
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="经销商" align="center">
  110. <template slot-scope="scope">
  111. {{ getDealerName(scope.row.dealer) }}
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="操作" align="center">
  115. <template slot-scope="scope">
  116. <el-tooltip
  117. class="item"
  118. effect="dark"
  119. content="编辑"
  120. placement="top"
  121. >
  122. <el-button
  123. size="mini"
  124. type="primary"
  125. icon="el-icon-edit-outline"
  126. @click="handleEdit(scope.$index, scope.row)"
  127. >
  128. </el-button>
  129. </el-tooltip>
  130. <el-tooltip
  131. class="item"
  132. effect="dark"
  133. content="删除"
  134. placement="top"
  135. >
  136. <el-button
  137. size="mini"
  138. type="danger"
  139. icon="el-icon-delete"
  140. @click="handleDelete(scope.$index, scope.row)"
  141. >
  142. </el-button>
  143. </el-tooltip>
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. <el-pagination
  148. @size-change="handleSizeChange"
  149. @current-change="handleCurrentChange"
  150. :page-sizes="[10, 50, 100]"
  151. :page-size="10"
  152. background
  153. style="margin-top:20px;float: right"
  154. layout="total, sizes, prev, pager, next, jumper"
  155. :total="total"
  156. >
  157. </el-pagination>
  158. </div>
  159. </div>
  160. </template>
  161. <script>
  162. import { uParseTime } from "@/utils/tools";
  163. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  164. import {
  165. deleteWarehouseOut,
  166. GetAllConfig,
  167. getWarehouseOutList
  168. } from "@/api/stock";
  169. import BreadCrumb from "../components/bread-crumb";
  170. export default {
  171. name: "salesReturnOrder",
  172. components: { BreadCrumb },
  173. created() {
  174. var nowDate = new Date();
  175. var nowYear = nowDate.getFullYear();
  176. var nowMonth = nowDate.getMonth() + 1;
  177. var nowDay = nowDate.getDate();
  178. this.end_time =
  179. nowYear +
  180. "-" +
  181. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  182. "-" +
  183. (nowDay < 10 ? "0" + nowDay : nowDay);
  184. nowDate.setMonth(nowDate.getMonth() - 1);
  185. nowYear = nowDate.getFullYear();
  186. nowMonth = nowDate.getMonth() + 1;
  187. nowDay = nowDate.getDate();
  188. this.start_time =
  189. nowYear +
  190. "-" +
  191. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  192. "-" +
  193. (nowDay < 10 ? "0" + nowDay : nowDay);
  194. this.GetWarehouseOut();
  195. this.GetConfigInfo();
  196. this.fetchAllAdminUsers();
  197. },
  198. data() {
  199. return {
  200. searchKey: "",
  201. crumbs: [
  202. { path: false, name: "库存管理" },
  203. { path: false, name: "出库单" }
  204. ],
  205. page: 1,
  206. limit: 10,
  207. checked: false,
  208. total: 0,
  209. pageTotal: 0,
  210. pageSelect: 0,
  211. adminUserOptions: [],
  212. multipleSelection: [],
  213. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  214. start_time: "",
  215. warehouseOutDate: [],
  216. end_time: "",
  217. goodType: [],
  218. goodInfo: [],
  219. manufacturer: [],
  220. selectedTableData: [],
  221. dealer: [],
  222. type: 1
  223. };
  224. },
  225. methods: {
  226. search: function() {
  227. const Params = {
  228. page: this.page,
  229. limit: this.limit,
  230. start_time: this.start_time,
  231. end_time: this.end_time,
  232. type: this.type,
  233. keywords: this.searchKey
  234. };
  235. this.warehouseOutDate = [];
  236. getWarehouseOutList(Params).then(response => {
  237. if (response.data.state == 0) {
  238. this.$message.error(response.data.msg);
  239. return false;
  240. } else {
  241. this.total = response.data.data.total;
  242. for (let i = 0; i < response.data.data.list.length; i++) {
  243. this.warehouseOutDate.push(response.data.data.list[i]);
  244. }
  245. }
  246. });
  247. },
  248. AddNewOrder: function() {
  249. this.$router.push({
  250. name: "stockOutOrderAdd",
  251. query: { type: this.type }
  252. });
  253. },
  254. GetWarehouseOut: function() {
  255. const Params = {
  256. page: this.page,
  257. limit: this.limit,
  258. start_time: this.start_time,
  259. end_time: this.end_time,
  260. type: this.type
  261. };
  262. this.warehouseOutDate = [];
  263. getWarehouseOutList(Params).then(response => {
  264. if (response.data.state == 0) {
  265. this.$message.error(response.data.msg);
  266. return false;
  267. } else {
  268. this.total = response.data.data.total;
  269. for (let i = 0; i < response.data.data.list.length; i++) {
  270. this.warehouseOutDate.push(response.data.data.list[i]);
  271. }
  272. }
  273. });
  274. },
  275. getXuserName(id) {
  276. if (id <= 0) {
  277. return "";
  278. }
  279. var name = "";
  280. if (
  281. this.adminUserOptions == null ||
  282. typeof this.adminUserOptions.length === "undefined"
  283. ) {
  284. return name;
  285. }
  286. var leng = this.adminUserOptions.length;
  287. if (leng == 0) {
  288. return name;
  289. }
  290. for (let index = 0; index < leng; index++) {
  291. if (this.adminUserOptions[index].id == id) {
  292. name = this.adminUserOptions[index].name;
  293. break;
  294. }
  295. }
  296. return name;
  297. },
  298. fetchAllAdminUsers() {
  299. fetchAllAdminUsers().then(response => {
  300. console.log(response);
  301. if (response.data.state == 1) {
  302. this.adminUserOptions = response.data.data.users;
  303. var alen = this.adminUserOptions.length;
  304. for (let index = 0; index < alen; index++) {
  305. if (this.adminUserOptions[index].user_type == 2) {
  306. // this.doctorOptions.push(this.adminUserOptions[index]);
  307. }
  308. }
  309. }
  310. });
  311. },
  312. handleSelectionChange: function(val) {
  313. this.multipleSelection = val;
  314. },
  315. handleSizeChange(val) {
  316. this.limit = val;
  317. this.GetWarehouseOut();
  318. },
  319. handleCurrentChange(val) {
  320. this.page = val;
  321. this.GetWarehouseOut();
  322. },
  323. startTimeChange(val) {
  324. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  325. if (time > 0) {
  326. this.$message.error("结束时间不能小于开始时间");
  327. this.start_time = "";
  328. } else {
  329. this.GetWarehouseOut();
  330. }
  331. this.GetWarehouseOut();
  332. },
  333. endTimeChange(val) {
  334. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  335. if (time < 0) {
  336. this.$message.error("结束时间不能小于开始时间");
  337. this.end_time = "";
  338. } else {
  339. this.GetWarehouseOut();
  340. }
  341. },
  342. getTimestamp(time) {
  343. // 把时间日期转成时间戳
  344. return new Date(time).getTime() / 1000;
  345. },
  346. calculate: function(val) {
  347. return Math.round(parseFloat(val) * 100) / 100;
  348. },
  349. GetConfigInfo: function() {
  350. GetAllConfig().then(response => {
  351. if (response.data.state == 0) {
  352. this.$message.error(response.data.msg);
  353. return false;
  354. } else {
  355. this.manufacturer = response.data.data.manufacturer;
  356. this.dealer = response.data.data.dealer;
  357. }
  358. });
  359. },
  360. getManufactuerName: function(manufacturer_id) {
  361. for (let i = 0; i < this.manufacturer.length; i++) {
  362. if (this.manufacturer[i].id == manufacturer_id) {
  363. return this.manufacturer[i].manufacturer_name;
  364. }
  365. }
  366. },
  367. getDealerName: function(dealer_id) {
  368. for (let i = 0; i < this.dealer.length; i++) {
  369. if (this.dealer[i].id == dealer_id) {
  370. return this.dealer[i].dealer_name;
  371. }
  372. }
  373. },
  374. handleEdit: function(index, row) {
  375. this.$router.push({
  376. name: "stockOutDetail",
  377. query: { id: row.id, type: this.type }
  378. });
  379. },
  380. handleDelete: function(index, row) {
  381. const ids = [];
  382. ids.push(row.id);
  383. const idStr = ids.join(",");
  384. const params = {
  385. ids: idStr
  386. };
  387. this.$confirm("确认删除出库单记录?", "删除出库单记录", {
  388. confirmButtonText: "确定",
  389. cancelButtonText: "取消",
  390. type: "warning"
  391. })
  392. .then(() => {
  393. deleteWarehouseOut(params).then(response => {
  394. if (response.data.state == 0) {
  395. this.$message.error(response.data.msg);
  396. return false;
  397. } else {
  398. this.$notify({
  399. title: "成功",
  400. message: "删除成功",
  401. type: "success",
  402. duration: 2000
  403. });
  404. for (let i = 0; i < ids.length; i++) {
  405. for (let y = 0; y < this.warehouseOutDate.length; y++) {
  406. if (ids[i] == this.warehouseOutDate[y].id) {
  407. this.warehouseOutDate.splice(y, 1);
  408. }
  409. }
  410. }
  411. }
  412. });
  413. })
  414. .catch(() => {});
  415. },
  416. changeAllSelected: function(val) {
  417. if (val) {
  418. this.$refs.multipleTable.toggleAllSelection();
  419. } else {
  420. this.$refs.multipleTable.clearSelection();
  421. }
  422. },
  423. select(selection) {
  424. this.selectedTableData = selection;
  425. },
  426. batchDelete() {
  427. if (this.selectedTableData.length <= 0) {
  428. this.$message.error("请选择要删除的记录");
  429. return;
  430. }
  431. const ids = [];
  432. for (let i = 0; i < this.selectedTableData.length; i++) {
  433. ids.push(this.selectedTableData[i].id);
  434. }
  435. const idStr = ids.join(",");
  436. const params = {
  437. ids: idStr
  438. };
  439. this.$confirm("确认删除退货单记录?", "删除退货单记录", {
  440. confirmButtonText: "确定",
  441. cancelButtonText: "取消",
  442. type: "warning"
  443. })
  444. .then(() => {
  445. deleteWarehouseOut(params).then(response => {
  446. if (response.data.state == 0) {
  447. this.$message.error(response.data.msg);
  448. return false;
  449. } else {
  450. this.$notify({
  451. title: "成功",
  452. message: "删除成功",
  453. type: "success",
  454. duration: 2000
  455. });
  456. for (let i = 0; i < ids.length; i++) {
  457. for (let y = 0; y < this.warehouseOutDate.length; y++) {
  458. if (ids[i] == this.warehouseOutDate[y].id) {
  459. this.warehouseOutDate.splice(y, 1);
  460. }
  461. }
  462. }
  463. }
  464. });
  465. })
  466. .catch(() => {});
  467. }
  468. }
  469. };
  470. </script>
  471. <style rel="stylesheet/scss" lang="scss">
  472. .app-container {
  473. // margin: 20px;
  474. font-size: 15px;
  475. .filter-container {
  476. padding-bottom: 5px;
  477. }
  478. .search-component {
  479. width: 500px;
  480. .searchBox {
  481. width: 300px;
  482. height: 36px;
  483. line-height: 36px;
  484. padding-left: 15px;
  485. border: 1px #dcdfe6 solid;
  486. border-right: none;
  487. outline: none;
  488. float: left;
  489. border-radius: 6px 0 0 6px;
  490. font-size: 14px;
  491. color: #333;
  492. background: #fff;
  493. box-shadow: 3px 3px 4px rgba(135, 135, 135, 0.05);
  494. }
  495. .searchBtn {
  496. background-color: #409eff;
  497. color: #fff;
  498. font-size: 15px;
  499. text-align: center;
  500. height: 36px;
  501. line-height: 36px;
  502. float: left;
  503. outline: none;
  504. width: 70px;
  505. border: none;
  506. border-radius: 0 6px 6px 0;
  507. font-family: "Microsoft Yahei";
  508. cursor: pointer;
  509. }
  510. }
  511. .amount {
  512. font-weight: normal;
  513. padding: 10px 0 0 0;
  514. color: #606266;
  515. font-size: 14px;
  516. span {
  517. color: #ef2525;
  518. font-family: "Arial";
  519. padding: 0 2px;
  520. }
  521. }
  522. }
  523. .el-table td,
  524. .el-table th.is-leaf,
  525. .el-table--border,
  526. .el-table--group {
  527. border-color: #d0d3da;
  528. }
  529. .el-table--border::after,
  530. .el-table--group::after,
  531. .el-table::before {
  532. background-color: #d0d3da;
  533. }
  534. </style>