cancelDrugStockOrder.vue 15KB

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