cancelStockDetail.vue 15KB

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