salesReturnOrder.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. >新增
  13. </el-button>
  14. </div>
  15. <div class="app-container">
  16. <div class="cell clearfix">
  17. <el-input
  18. style="width: 400px;"
  19. class="filter-item"
  20. v-model.trim="searchKey"
  21. placeholder="单据编码/制单人/厂商"
  22. />
  23. <el-button
  24. class="filter-item"
  25. type="primary"
  26. icon="el-icon-search"
  27. @click="search"
  28. >搜索</el-button
  29. >
  30. </div>
  31. <div class="cell clearfix">
  32. <label class="title"><span class="name">退货时间</span> : </label>
  33. <el-date-picker
  34. size="small"
  35. v-model="start_time"
  36. prefix-icon="el-icon-date"
  37. :editable="false"
  38. style="width: 196px;"
  39. type="date"
  40. placeholder="选择日期时间"
  41. align="right"
  42. format="yyyy-MM-dd"
  43. value-format="yyyy-MM-dd"
  44. @change="startTimeChange"
  45. ></el-date-picker>
  46. <span class="cellLine"> - </span>
  47. <el-date-picker
  48. size="small"
  49. v-model="end_time"
  50. prefix-icon="el-icon-date"
  51. :editable="false"
  52. style="width: 196px;"
  53. type="date"
  54. placeholder="选择日期时间"
  55. align="right"
  56. format="yyyy-MM-dd"
  57. value-format="yyyy-MM-dd"
  58. @change="endTimeChange"
  59. ></el-date-picker>
  60. </div>
  61. <div class="cell clearfix" style="margin-top: 10px">
  62. <el-checkbox
  63. style="width: 70px"
  64. v-model="checked"
  65. @change="changeAllSelected"
  66. >全选</el-checkbox
  67. >
  68. <el-button size="small" icon="el-icon-delete" @click="batchDelete"
  69. >删除</el-button
  70. >
  71. </div>
  72. <el-table
  73. :data="saleReturnDate"
  74. :class="signAndWeighBoxPatients"
  75. style="width: 100%"
  76. border
  77. highlight-current-row
  78. ref="multipleTable"
  79. @selection-change="select"
  80. :row-style="{ color: '#303133' }"
  81. :header-cell-style="{
  82. backgroundColor: 'rgb(245, 247, 250)',
  83. color: '#606266'
  84. }"
  85. >
  86. <el-table-column type="selection" width="55"> </el-table-column>
  87. <el-table-column label="单据日期" align="center">
  88. <template slot-scope="scope">
  89. {{ scope.row.opera_time | parseTime("{y}-{m}-{d}") }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="单据编号" align="center">
  93. <template slot-scope="scope">
  94. {{ scope.row.order_number }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="制单人" align="center">
  98. <template slot-scope="scope">
  99. {{ getXuserName(scope.row.creater) }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="厂家" align="center">
  103. <template slot-scope="scope">
  104. {{ getManufactuerName(scope.row.manufacturer) }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="经销商" align="center">
  108. <template slot-scope="scope">
  109. {{ getDealerName(scope.row.dealer) }}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" align="center">
  113. <template slot-scope="scope">
  114. <el-tooltip
  115. class="item"
  116. effect="dark"
  117. content="编辑"
  118. placement="top"
  119. >
  120. <el-button
  121. size="mini"
  122. type="primary"
  123. icon="el-icon-edit-outline"
  124. @click="handleEdit(scope.$index, scope.row)"
  125. >
  126. </el-button>
  127. </el-tooltip>
  128. <el-tooltip
  129. class="item"
  130. effect="dark"
  131. content="删除"
  132. placement="top"
  133. >
  134. <el-button
  135. size="mini"
  136. type="danger"
  137. icon="el-icon-delete"
  138. @click="handleDelete(scope.$index, scope.row)"
  139. >
  140. </el-button>
  141. </el-tooltip>
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. <el-pagination
  146. @size-change="handleSizeChange"
  147. @current-change="handleCurrentChange"
  148. :page-sizes="[10, 50, 100]"
  149. :page-size="10"
  150. background
  151. style="margin-top:20px;float: right"
  152. layout="total, sizes, prev, pager, next, jumper"
  153. :total="total"
  154. >
  155. </el-pagination>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import { uParseTime } from "@/utils/tools";
  161. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  162. import {
  163. deleteSalesReturn,
  164. GetAllConfig,
  165. getSalesReturnList,
  166. getWarehouseInfoList,
  167. getWarehouseList
  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.GetSalesReturn();
  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. type: 1,
  206. page: 1,
  207. limit: 10,
  208. checked: false,
  209. total: 0,
  210. pageTotal: 0,
  211. pageSelect: 0,
  212. adminUserOptions: [],
  213. multipleSelection: [],
  214. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  215. start_time: "",
  216. saleReturnDate: [],
  217. end_time: "",
  218. goodType: [],
  219. goodInfo: [],
  220. manufacturer: [],
  221. selectedTableData: [],
  222. dealer: []
  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.saleReturnDate = [];
  236. getSalesReturnList(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.saleReturnDate.push(response.data.data.list[i]);
  244. }
  245. }
  246. });
  247. },
  248. AddNewOrder: function() {
  249. this.$router.push({
  250. name: "salesReturnOrderAdd",
  251. query: { type: this.type }
  252. });
  253. },
  254. GetSalesReturn: 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.saleReturnDate = [];
  263. getSalesReturnList(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.saleReturnDate.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.GetSalesReturn();
  318. },
  319. handleCurrentChange(val) {
  320. this.page = val;
  321. this.GetSalesReturn();
  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.GetSalesReturn();
  330. }
  331. this.GetSalesReturn();
  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.GetWarehouse();
  340. }
  341. this.GetSalesReturn();
  342. },
  343. getTimestamp(time) {
  344. // 把时间日期转成时间戳
  345. return new Date(time).getTime() / 1000;
  346. },
  347. calculate: function(val) {
  348. return Math.round(parseFloat(val) * 100) / 100;
  349. },
  350. GetConfigInfo: function() {
  351. GetAllConfig().then(response => {
  352. if (response.data.state == 0) {
  353. this.$message.error(response.data.msg);
  354. return false;
  355. } else {
  356. this.manufacturer = response.data.data.manufacturer;
  357. this.dealer = response.data.data.dealer;
  358. }
  359. });
  360. },
  361. getManufactuerName: function(manufacturer_id) {
  362. for (let i = 0; i < this.manufacturer.length; i++) {
  363. if (this.manufacturer[i].id == manufacturer_id) {
  364. return this.manufacturer[i].manufacturer_name;
  365. }
  366. }
  367. },
  368. getDealerName: function(dealer_id) {
  369. for (let i = 0; i < this.dealer.length; i++) {
  370. if (this.dealer[i].id == dealer_id) {
  371. return this.dealer[i].dealer_name;
  372. }
  373. }
  374. },
  375. handleEdit: function(index, row) {
  376. this.$router.push({
  377. name: "salesReturnDetail",
  378. query: { id: row.id, type: this.type }
  379. });
  380. },
  381. handleDelete: function(index, row) {
  382. const ids = [];
  383. ids.push(row.id);
  384. const idStr = ids.join(",");
  385. const params = {
  386. ids: idStr
  387. };
  388. this.$confirm("确认删除退货单记录?", "删除退货单记录", {
  389. confirmButtonText: "确定",
  390. cancelButtonText: "取消",
  391. type: "warning"
  392. })
  393. .then(() => {
  394. deleteSalesReturn(params).then(response => {
  395. if (response.data.state == 0) {
  396. this.$message.error(response.data.msg);
  397. return false;
  398. } else {
  399. this.$notify({
  400. title: "成功",
  401. message: "删除成功",
  402. type: "success",
  403. duration: 2000
  404. });
  405. for (let i = 0; i < ids.length; i++) {
  406. for (let y = 0; y < this.saleReturnDate.length; y++) {
  407. if (ids[i] == this.saleReturnDate[y].id) {
  408. this.saleReturnDate.splice(y, 1);
  409. }
  410. }
  411. }
  412. }
  413. });
  414. })
  415. .catch(() => {});
  416. },
  417. changeAllSelected: function(val) {
  418. if (val) {
  419. this.$refs.multipleTable.toggleAllSelection();
  420. } else {
  421. this.$refs.multipleTable.clearSelection();
  422. }
  423. },
  424. select(selection) {
  425. this.selectedTableData = selection;
  426. },
  427. batchDelete() {
  428. if (this.selectedTableData.length <= 0) {
  429. this.$message.error("请选择要删除的记录");
  430. return;
  431. }
  432. const ids = [];
  433. for (let i = 0; i < this.selectedTableData.length; i++) {
  434. ids.push(this.selectedTableData[i].id);
  435. }
  436. const idStr = ids.join(",");
  437. const params = {
  438. ids: idStr
  439. };
  440. this.$confirm("确认删除退货单记录?", "删除退货单记录", {
  441. confirmButtonText: "确定",
  442. cancelButtonText: "取消",
  443. type: "warning"
  444. })
  445. .then(() => {
  446. deleteSalesReturn(params).then(response => {
  447. if (response.data.state == 0) {
  448. this.$message.error(response.data.msg);
  449. return false;
  450. } else {
  451. this.$notify({
  452. title: "成功",
  453. message: "删除成功",
  454. type: "success",
  455. duration: 2000
  456. });
  457. for (let i = 0; i < ids.length; i++) {
  458. for (let y = 0; y < this.saleReturnDate.length; y++) {
  459. if (ids[i] == this.saleReturnDate[y].id) {
  460. this.saleReturnDate.splice(y, 1);
  461. }
  462. }
  463. }
  464. }
  465. });
  466. })
  467. .catch(() => {});
  468. }
  469. }
  470. };
  471. </script>
  472. <style rel="stylesheet/css" lang="scss" scoped>
  473. .information {
  474. border: 1px #dcdfe6 solid;
  475. padding: 30px 20px 30px 20px;
  476. .border {
  477. border-bottom: 1px #dcdfe6 solid;
  478. margin: 0px 0 20px 0;
  479. }
  480. }
  481. .edit_separater {
  482. border-top: 1px solid rgb(233, 233, 233);
  483. margin-top: 15px;
  484. margin-bottom: 15px;
  485. }
  486. .cell {
  487. text-align: center;
  488. }
  489. </style>
  490. <style>
  491. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  492. font-size: 12px;
  493. }
  494. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  495. background: #6fb5fa;
  496. }
  497. .count {
  498. color: #bd2c00;
  499. }
  500. .el-table td,
  501. .el-table th.is-leaf,
  502. .el-table--border,
  503. .el-table--group {
  504. border-color: #d0d3da;
  505. }
  506. .el-table--border::after,
  507. .el-table--group::after,
  508. .el-table::before {
  509. background-color: #d0d3da;
  510. }
  511. </style>