otherCancelStockOrder.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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. 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="filter-container" style="margin-top: 10px">
  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="cancelStockDate"
  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.return_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.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. deleteCancelStock,
  166. GetAllConfig,
  167. getCancelStockList
  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.GetCancelStock();
  195. this.GetConfigInfo();
  196. this.fetchAllAdminUsers();
  197. },
  198. data() {
  199. return {
  200. crumbs: [
  201. { path: false, name: "库存管理" },
  202. { path: "/stock/cancel", name: "其他出库退库单" }
  203. ],
  204. searchKey: "",
  205. type: 2,
  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. cancelStockDate: [],
  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.cancelStockDate = [];
  236. getCancelStockList(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.cancelStockDate.push(response.data.data.list[i]);
  244. }
  245. }
  246. });
  247. },
  248. AddNewOrder: function() {
  249. this.$router.push({
  250. name: "cancelStockOrderAdd",
  251. query: { type: this.type }
  252. });
  253. },
  254. GetCancelStock: 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.cancelStockDate = [];
  263. getCancelStockList(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.cancelStockDate.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.GetCancelStock();
  318. },
  319. handleCurrentChange(val) {
  320. this.page = val;
  321. this.GetCancelStock();
  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.GetCancelStock();
  330. }
  331. },
  332. endTimeChange(val) {
  333. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  334. if (time < 0) {
  335. this.$message.error("结束时间不能小于开始时间");
  336. this.end_time = "";
  337. } else {
  338. this.GetCancelStock();
  339. }
  340. },
  341. getTimestamp(time) {
  342. // 把时间日期转成时间戳
  343. return new Date(time).getTime() / 1000;
  344. },
  345. calculate: function(val) {
  346. return Math.round(parseFloat(val) * 100) / 100;
  347. },
  348. GetConfigInfo: function() {
  349. GetAllConfig().then(response => {
  350. if (response.data.state == 0) {
  351. this.$message.error(response.data.msg);
  352. return false;
  353. } else {
  354. this.manufacturer = response.data.data.manufacturer;
  355. this.dealer = response.data.data.dealer;
  356. }
  357. });
  358. },
  359. getManufactuerName: function(manufacturer_id) {
  360. for (let i = 0; i < this.manufacturer.length; i++) {
  361. if (this.manufacturer[i].id == manufacturer_id) {
  362. return this.manufacturer[i].manufacturer_name;
  363. }
  364. }
  365. },
  366. getDealerName: function(dealer_id) {
  367. for (let i = 0; i < this.dealer.length; i++) {
  368. if (this.dealer[i].id == dealer_id) {
  369. return this.dealer[i].dealer_name;
  370. }
  371. }
  372. },
  373. handleEdit: function(index, row) {
  374. this.$router.push({
  375. name: "cancelStockDetail",
  376. query: { id: row.id, type: this.type }
  377. });
  378. },
  379. handleDelete: function(index, row) {
  380. const ids = [];
  381. ids.push(row.id);
  382. const idStr = ids.join(",");
  383. const params = {
  384. ids: idStr
  385. };
  386. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  387. confirmButtonText: "确定",
  388. cancelButtonText: "取消",
  389. type: "warning"
  390. })
  391. .then(() => {
  392. deleteCancelStock(params).then(response => {
  393. if (response.data.state == 0) {
  394. this.$message.error(response.data.msg);
  395. return false;
  396. } else {
  397. this.$notify({
  398. title: "成功",
  399. message: "删除成功",
  400. type: "success",
  401. duration: 2000
  402. });
  403. for (let i = 0; i < ids.length; i++) {
  404. for (let y = 0; y < this.cancelStockDate.length; y++) {
  405. if (ids[i] == this.cancelStockDate[y].id) {
  406. this.cancelStockDate.splice(y, 1);
  407. }
  408. }
  409. }
  410. }
  411. });
  412. })
  413. .catch(() => {});
  414. },
  415. changeAllSelected: function(val) {
  416. if (val) {
  417. this.$refs.multipleTable.toggleAllSelection();
  418. } else {
  419. this.$refs.multipleTable.clearSelection();
  420. }
  421. },
  422. select(selection) {
  423. this.selectedTableData = selection;
  424. },
  425. batchDelete() {
  426. if (this.selectedTableData.length <= 0) {
  427. this.$message.error("请选择要删除的记录");
  428. return;
  429. }
  430. const ids = [];
  431. for (let i = 0; i < this.selectedTableData.length; i++) {
  432. ids.push(this.selectedTableData[i].id);
  433. }
  434. const idStr = ids.join(",");
  435. const params = {
  436. ids: idStr
  437. };
  438. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  439. confirmButtonText: "确定",
  440. cancelButtonText: "取消",
  441. type: "warning"
  442. })
  443. .then(() => {
  444. deleteCancelStock(params).then(response => {
  445. if (response.data.state == 0) {
  446. this.$message.error(response.data.msg);
  447. return false;
  448. } else {
  449. this.$notify({
  450. title: "成功",
  451. message: "删除成功",
  452. type: "success",
  453. duration: 2000
  454. });
  455. for (let i = 0; i < ids.length; i++) {
  456. for (let y = 0; y < this.cancelStockDate.length; y++) {
  457. if (ids[i] == this.cancelStockDate[y].id) {
  458. this.cancelStockDate.splice(y, 1);
  459. }
  460. }
  461. }
  462. }
  463. });
  464. })
  465. .catch(() => {});
  466. }
  467. }
  468. };
  469. </script>
  470. <style rel="stylesheet/css" lang="scss" scoped>
  471. .information {
  472. border: 1px #dcdfe6 solid;
  473. padding: 30px 20px 30px 20px;
  474. .border {
  475. border-bottom: 1px #dcdfe6 solid;
  476. margin: 0px 0 20px 0;
  477. }
  478. }
  479. .edit_separater {
  480. border-top: 1px solid rgb(233, 233, 233);
  481. margin-top: 15px;
  482. margin-bottom: 15px;
  483. }
  484. </style>
  485. <style>
  486. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  487. font-size: 12px;
  488. }
  489. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  490. background: #6fb5fa;
  491. }
  492. .count {
  493. color: #bd2c00;
  494. }
  495. .el-table td,
  496. .el-table th.is-leaf,
  497. .el-table--border,
  498. .el-table--group {
  499. border-color: #d0d3da;
  500. }
  501. .el-table--border::after,
  502. .el-table--group::after,
  503. .el-table::before {
  504. background-color: #d0d3da;
  505. }
  506. </style>