drugStockOutOrder.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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" align="center"> </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 min-width="35" align="center">
  105. <template slot="header" slot-scope="scope">
  106. <span>出库方式</span>
  107. </template>
  108. <template slot-scope="scope">
  109. <span v-if="scope.row.is_sys == 1">{{"自动出库"}}</span>
  110. <span v-if="scope.row.is_sys != 1">{{"手动出库"}}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="厂家" align="center">
  114. <template slot-scope="scope">
  115. {{scope.row.manufacturers ? scope.row.manufacturers.manufacturer_name:''}}
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="经销商" align="center">
  119. <template slot-scope="scope">
  120. {{scope.row.dealers ? scope.row.dealers.dealer_name:''}}
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="操作" align="center">
  124. <template slot-scope="scope">
  125. <el-tooltip
  126. class="item"
  127. effect="dark"
  128. content="编辑"
  129. placement="top"
  130. >
  131. <el-button
  132. size="mini"
  133. type="primary"
  134. icon="el-icon-edit-outline"
  135. @click="handleEdit(scope.$index, scope.row)"
  136. >
  137. </el-button>
  138. </el-tooltip>
  139. <el-tooltip
  140. class="item"
  141. effect="dark"
  142. content="删除"
  143. placement="top"
  144. >
  145. <el-button
  146. size="mini"
  147. type="danger"
  148. :disabled="scope.row.is_sys == 1"
  149. icon="el-icon-delete"
  150. @click="handleDelete(scope.$index, scope.row)"
  151. >
  152. </el-button>
  153. </el-tooltip>
  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. </div>
  169. </div>
  170. </template>
  171. <script>
  172. import { uParseTime } from "@/utils/tools";
  173. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  174. import {
  175. deleteDrugWarehouseOut,
  176. GetAllConfig,
  177. getDrugWarehouseOutList
  178. } from "@/api/drug/drug_stock";
  179. import BreadCrumb from "../../components/bread-crumb";
  180. export default {
  181. name: "salesReturnOrder",
  182. components: { BreadCrumb },
  183. created() {
  184. var nowDate = new Date();
  185. var nowYear = nowDate.getFullYear();
  186. var nowMonth = nowDate.getMonth() + 1;
  187. var nowDay = nowDate.getDate();
  188. this.end_time =
  189. nowYear +
  190. "-" +
  191. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  192. "-" +
  193. (nowDay < 10 ? "0" + nowDay : nowDay);
  194. nowDate.setMonth(nowDate.getMonth() - 1);
  195. nowYear = nowDate.getFullYear();
  196. nowMonth = nowDate.getMonth() + 1;
  197. nowDay = nowDate.getDate();
  198. this.start_time =
  199. nowYear +
  200. "-" +
  201. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  202. "-" +
  203. (nowDay < 10 ? "0" + nowDay : nowDay);
  204. this.GetWarehouseOut();
  205. this.GetConfigInfo();
  206. this.fetchAllAdminUsers();
  207. },
  208. data() {
  209. return {
  210. searchKey: "",
  211. crumbs: [
  212. { path: false, name: "库存管理" },
  213. { path: false, name: "出库单" }
  214. ],
  215. page: 1,
  216. limit: 10,
  217. checked: false,
  218. total: 0,
  219. pageTotal: 0,
  220. pageSelect: 0,
  221. adminUserOptions: [],
  222. multipleSelection: [],
  223. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  224. start_time: "",
  225. warehouseOutDate: [],
  226. end_time: "",
  227. goodType: [],
  228. goodInfo: [],
  229. manufacturer: [],
  230. selectedTableData: [],
  231. dealer: [],
  232. type: 1
  233. };
  234. },
  235. methods: {
  236. search: function() {
  237. const Params = {
  238. page: this.page,
  239. limit: this.limit,
  240. start_time: this.start_time,
  241. end_time: this.end_time,
  242. type: this.type,
  243. keywords: this.searchKey
  244. };
  245. this.warehouseOutDate = [];
  246. getDrugWarehouseOutList(Params).then(response => {
  247. if (response.data.state == 0) {
  248. this.$message.error(response.data.msg);
  249. return false;
  250. } else {
  251. this.total = response.data.data.total;
  252. for (let i = 0; i < response.data.data.list.length; i++) {
  253. this.warehouseOutDate.push(response.data.data.list[i]);
  254. }
  255. }
  256. });
  257. },
  258. AddNewOrder: function() {
  259. this.$router.push({
  260. name: "drugStockOutOrderAdd",
  261. query: { type: this.type }
  262. });
  263. },
  264. GetWarehouseOut: function() {
  265. const Params = {
  266. page: this.page,
  267. limit: this.limit,
  268. start_time: this.start_time,
  269. end_time: this.end_time,
  270. type: this.type
  271. };
  272. this.warehouseOutDate = [];
  273. getDrugWarehouseOutList(Params).then(response => {
  274. if (response.data.state == 0) {
  275. this.$message.error(response.data.msg);
  276. return false;
  277. } else {
  278. this.total = response.data.data.total;
  279. for (let i = 0; i < response.data.data.list.length; i++) {
  280. this.warehouseOutDate.push(response.data.data.list[i]);
  281. }
  282. }
  283. });
  284. },
  285. getXuserName(id) {
  286. if (id <= 0) {
  287. return "";
  288. }
  289. var name = "";
  290. if (
  291. this.adminUserOptions == null ||
  292. typeof this.adminUserOptions.length === "undefined"
  293. ) {
  294. return name;
  295. }
  296. var leng = this.adminUserOptions.length;
  297. if (leng == 0) {
  298. return name;
  299. }
  300. for (let index = 0; index < leng; index++) {
  301. if (this.adminUserOptions[index].id == id) {
  302. name = this.adminUserOptions[index].name;
  303. break;
  304. }
  305. }
  306. return name;
  307. },
  308. fetchAllAdminUsers() {
  309. fetchAllAdminUsers().then(response => {
  310. console.log(response);
  311. if (response.data.state == 1) {
  312. this.adminUserOptions = response.data.data.users;
  313. var alen = this.adminUserOptions.length;
  314. for (let index = 0; index < alen; index++) {
  315. if (this.adminUserOptions[index].user_type == 2) {
  316. // this.doctorOptions.push(this.adminUserOptions[index]);
  317. }
  318. }
  319. }
  320. });
  321. },
  322. handleSelectionChange: function(val) {
  323. this.multipleSelection = val;
  324. },
  325. handleSizeChange(val) {
  326. this.limit = val;
  327. this.GetWarehouseOut();
  328. },
  329. handleCurrentChange(val) {
  330. this.page = val;
  331. this.GetWarehouseOut();
  332. },
  333. startTimeChange(val) {
  334. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  335. if (time > 0) {
  336. this.$message.error("结束时间不能小于开始时间");
  337. this.start_time = "";
  338. } else {
  339. this.GetWarehouseOut();
  340. }
  341. this.GetWarehouseOut();
  342. },
  343. endTimeChange(val) {
  344. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  345. if (time < 0) {
  346. this.$message.error("结束时间不能小于开始时间");
  347. this.end_time = "";
  348. } else {
  349. this.GetWarehouseOut();
  350. }
  351. },
  352. getTimestamp(time) {
  353. // 把时间日期转成时间戳
  354. return new Date(time).getTime() / 1000;
  355. },
  356. calculate: function(val) {
  357. return Math.round(parseFloat(val) * 100) / 100;
  358. },
  359. GetConfigInfo: function() {
  360. GetAllConfig().then(response => {
  361. if (response.data.state == 0) {
  362. this.$message.error(response.data.msg);
  363. return false;
  364. } else {
  365. this.manufacturer = response.data.data.manufacturer;
  366. this.dealer = response.data.data.dealer;
  367. }
  368. });
  369. },
  370. handleEdit: function(index, row) {
  371. this.$router.push({
  372. name: "drugStockOutDetail",
  373. query: { id: row.id, type: this.type }
  374. });
  375. },
  376. handleDelete: function(index, row) {
  377. const ids = [];
  378. ids.push(row.id);
  379. const idStr = ids.join(",");
  380. const params = {
  381. ids: idStr
  382. };
  383. this.$confirm("确认删除出库单记录?", "删除出库单记录", {
  384. confirmButtonText: "确定",
  385. cancelButtonText: "取消",
  386. type: "warning"
  387. })
  388. .then(() => {
  389. deleteDrugWarehouseOut(params).then(response => {
  390. if (response.data.state == 0) {
  391. this.$message.error(response.data.msg);
  392. return false;
  393. } else {
  394. this.$notify({
  395. title: "成功",
  396. message: "删除成功",
  397. type: "success",
  398. duration: 2000
  399. });
  400. for (let i = 0; i < ids.length; i++) {
  401. for (let y = 0; y < this.warehouseOutDate.length; y++) {
  402. if (ids[i] == this.warehouseOutDate[y].id) {
  403. this.warehouseOutDate.splice(y, 1);
  404. }
  405. }
  406. }
  407. }
  408. });
  409. })
  410. .catch(() => {});
  411. },
  412. changeAllSelected: function(val) {
  413. if (val) {
  414. this.$refs.multipleTable.toggleAllSelection();
  415. } else {
  416. this.$refs.multipleTable.clearSelection();
  417. }
  418. },
  419. select(selection) {
  420. this.selectedTableData = selection;
  421. },
  422. batchDelete() {
  423. if (this.selectedTableData.length <= 0) {
  424. this.$message.error("请选择要删除的记录");
  425. return;
  426. }
  427. const ids = [];
  428. for (let i = 0; i < this.selectedTableData.length; i++) {
  429. ids.push(this.selectedTableData[i].id);
  430. }
  431. const idStr = ids.join(",");
  432. const params = {
  433. ids: idStr
  434. };
  435. this.$confirm("确认删除退货单记录?", "删除退货单记录", {
  436. confirmButtonText: "确定",
  437. cancelButtonText: "取消",
  438. type: "warning"
  439. })
  440. .then(() => {
  441. deleteDrugWarehouseOut(params).then(response => {
  442. if (response.data.state == 0) {
  443. this.$message.error(response.data.msg);
  444. return false;
  445. } else {
  446. this.$notify({
  447. title: "成功",
  448. message: "删除成功",
  449. type: "success",
  450. duration: 2000
  451. });
  452. for (let i = 0; i < ids.length; i++) {
  453. for (let y = 0; y < this.warehouseOutDate.length; y++) {
  454. if (ids[i] == this.warehouseOutDate[y].id) {
  455. this.warehouseOutDate.splice(y, 1);
  456. }
  457. }
  458. }
  459. }
  460. });
  461. })
  462. .catch(() => {});
  463. }
  464. }
  465. };
  466. </script>
  467. <style rel="stylesheet/scss" lang="scss">
  468. .app-container {
  469. // margin: 20px;
  470. font-size: 15px;
  471. .filter-container {
  472. padding-bottom: 5px;
  473. }
  474. .search-component {
  475. width: 500px;
  476. .searchBox {
  477. width: 300px;
  478. height: 36px;
  479. line-height: 36px;
  480. padding-left: 15px;
  481. border: 1px #dcdfe6 solid;
  482. border-right: none;
  483. outline: none;
  484. float: left;
  485. border-radius: 6px 0 0 6px;
  486. font-size: 14px;
  487. color: #333;
  488. background: #fff;
  489. box-shadow: 3px 3px 4px rgba(135, 135, 135, 0.05);
  490. }
  491. .searchBtn {
  492. background-color: #409eff;
  493. color: #fff;
  494. font-size: 15px;
  495. text-align: center;
  496. height: 36px;
  497. line-height: 36px;
  498. float: left;
  499. outline: none;
  500. width: 70px;
  501. border: none;
  502. border-radius: 0 6px 6px 0;
  503. font-family: "Microsoft Yahei";
  504. cursor: pointer;
  505. }
  506. }
  507. .amount {
  508. font-weight: normal;
  509. padding: 10px 0 0 0;
  510. color: #606266;
  511. font-size: 14px;
  512. span {
  513. color: #ef2525;
  514. font-family: "Arial";
  515. padding: 0 2px;
  516. }
  517. }
  518. }
  519. .el-table td,
  520. .el-table th.is-leaf,
  521. .el-table--border,
  522. .el-table--group {
  523. border-color: #d0d3da;
  524. }
  525. .el-table--border::after,
  526. .el-table--group::after,
  527. .el-table::before {
  528. background-color: #d0d3da;
  529. }
  530. </style>