stockDetail.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. v-model="start_time"
  37. prefix-icon="el-icon-date"
  38. :editable="false"
  39. style="width: 196px;"
  40. type="date"
  41. placeholder="选择日期时间"
  42. align="right"
  43. format="yyyy-MM-dd"
  44. value-format="yyyy-MM-dd"
  45. @change="startTimeChange"
  46. ></el-date-picker>
  47. <span class="cellLine"> - </span>
  48. <el-date-picker
  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="filter-container" style="margin-top: 10px">
  62. <el-checkbox
  63. style="width: 30px"
  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-row :gutter="12" style="margin-top: 10px">
  73. <el-table
  74. :data="cancelStockDate"
  75. :class="signAndWeighBoxPatients"
  76. border
  77. highlight-current-row
  78. ref="multipleTable"
  79. @selection-change="select"
  80. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  81. >
  82. <el-table-column label="单据编号" align="center">
  83. <template slot-scope="scope">
  84. {{ scope.row.warehousing_order }}
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="商品类型" align="center">
  88. <template slot-scope="scope">
  89. {{ specificationName(scope.row.good_id) }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="单据类型" align="center">
  93. <template slot-scope="scope">
  94. {{ getTypeName(scope.row) }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作时间" align="center">
  98. <template slot-scope="scope">
  99. {{ scope.row.warehousing_time | parseTime("{y}-{m}-{d}") }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="制单人" align="center">
  103. <template slot-scope="scope">
  104. {{ getXuserName(scope.row.creater) }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="单价" align="center">
  108. <template slot-scope="scope">
  109. {{ scope.row.price }}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="数量" align="center">
  113. <template slot-scope="scope">
  114. {{ scope.row.warehousing_count }}
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="总价" align="center">
  118. <template slot-scope="scope">
  119. {{ scope.row.price * scope.row.warehousing_count }}
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <el-pagination
  124. @size-change="handleSizeChange"
  125. @current-change="handleCurrentChange"
  126. :page-sizes="[7]"
  127. :page-size="7"
  128. background
  129. style="margin-top:20px;float: right"
  130. layout="total, sizes, prev, pager, next, jumper"
  131. :total="total"
  132. >
  133. </el-pagination>
  134. </el-row>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import { uParseTime } from "@/utils/tools";
  140. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  141. import { deleteCancelStock, GetAllConfig, getStockDetail } from "@/api/stock";
  142. import BreadCrumb from "../components/bread-crumb";
  143. export default {
  144. name: "salesReturnOrder",
  145. components: { BreadCrumb },
  146. created() {
  147. var year = new Date().getFullYear();
  148. var month = new Date().getMonth() + 1;
  149. var day = new Date().getDate();
  150. if (parseInt(month) < 10) {
  151. month = "0" + month;
  152. }
  153. if (parseInt(day) < 10) {
  154. day = "0" + day;
  155. }
  156. const endTime = year + "-" + month + "-" + day;
  157. this.end_time = endTime;
  158. var year = new Date().getFullYear();
  159. var month = new Date().getMonth();
  160. var day = new Date().getDate();
  161. if (parseInt(month) < 10) {
  162. month = "0" + month;
  163. }
  164. if (parseInt(day) < 10) {
  165. day = "0" + day;
  166. }
  167. const startTime = year + "-" + month + "-" + day;
  168. this.start_time = startTime;
  169. this.GetCancelStock();
  170. this.GetConfigInfo();
  171. this.fetchAllAdminUsers();
  172. },
  173. data() {
  174. return {
  175. crumbs: [
  176. { path: false, name: "库存管理" },
  177. { path: "/stock/detail", name: "出入库明细查询" }
  178. ],
  179. searchKey: "",
  180. type: 1,
  181. page: 1,
  182. limit: 7,
  183. checked: false,
  184. total: 0,
  185. pageTotal: 0,
  186. pageSelect: 0,
  187. adminUserOptions: [],
  188. multipleSelection: [],
  189. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  190. start_time: "",
  191. cancelStockDate: [],
  192. end_time: "",
  193. goodType: [],
  194. goodInfo: [],
  195. manufacturer: [],
  196. selectedTableData: [],
  197. dealer: []
  198. };
  199. },
  200. methods: {
  201. getTypeName: function(row) {
  202. let name = "";
  203. let name2 = "";
  204. if (row.type == 1) {
  205. name = "耗材";
  206. } else if (row.type == 2) {
  207. name = "其他";
  208. }
  209. if (row.types == 1) {
  210. name2 = "入库单";
  211. } else if (row.types == 2) {
  212. name2 = "出库单";
  213. } else if (row.types == 3) {
  214. name2 = "退货单";
  215. } else if (row.types == 4) {
  216. name2 = "退库单";
  217. }
  218. return name + name2;
  219. },
  220. specificationName: function(good_info_id) {
  221. let name = "";
  222. for (let i = 0; i < this.goodInfo.length; i++) {
  223. if (this.goodInfo[i].id == good_info_id) {
  224. name = this.goodInfo[i].specification_name;
  225. }
  226. }
  227. return name;
  228. },
  229. search: function() {
  230. const Params = {
  231. page: this.page,
  232. limit: this.limit,
  233. start_time: this.start_time,
  234. end_time: this.end_time,
  235. type: this.type,
  236. keywords: this.searchKey
  237. };
  238. this.cancelStockDate = [];
  239. getStockDetail(Params).then(response => {
  240. if (response.data.state == 0) {
  241. this.$message.error(response.data.msg);
  242. return false;
  243. } else {
  244. this.total = response.data.data.total;
  245. for (let i = 0; i < response.data.data.list.length; i++) {
  246. this.cancelStockDate.push(response.data.data.list[i]);
  247. }
  248. }
  249. });
  250. },
  251. AddNewOrder: function() {
  252. this.$router.push({
  253. name: "cancelStockOrderAdd",
  254. query: { type: this.type }
  255. });
  256. },
  257. GetCancelStock: function() {
  258. const Params = {
  259. page: this.page,
  260. limit: this.limit,
  261. start_time: this.start_time,
  262. end_time: this.end_time,
  263. type: this.type
  264. };
  265. this.cancelStockDate = [];
  266. getStockDetail(Params).then(response => {
  267. if (response.data.state == 0) {
  268. this.$message.error(response.data.msg);
  269. return false;
  270. } else {
  271. this.total = response.data.data.total;
  272. for (let i = 0; i < response.data.data.list.length; i++) {
  273. this.cancelStockDate.push(response.data.data.list[i]);
  274. }
  275. }
  276. });
  277. },
  278. getXuserName(id) {
  279. if (id <= 0) {
  280. return "";
  281. }
  282. var name = "";
  283. if (
  284. this.adminUserOptions == null ||
  285. typeof this.adminUserOptions.length === "undefined"
  286. ) {
  287. return name;
  288. }
  289. var leng = this.adminUserOptions.length;
  290. if (leng == 0) {
  291. return name;
  292. }
  293. for (let index = 0; index < leng; index++) {
  294. if (this.adminUserOptions[index].id == id) {
  295. name = this.adminUserOptions[index].name;
  296. break;
  297. }
  298. }
  299. return name;
  300. },
  301. fetchAllAdminUsers() {
  302. fetchAllAdminUsers().then(response => {
  303. console.log(response);
  304. if (response.data.state == 1) {
  305. this.adminUserOptions = response.data.data.users;
  306. var alen = this.adminUserOptions.length;
  307. for (let index = 0; index < alen; index++) {
  308. if (this.adminUserOptions[index].user_type == 2) {
  309. // this.doctorOptions.push(this.adminUserOptions[index]);
  310. }
  311. }
  312. }
  313. });
  314. },
  315. handleSelectionChange: function(val) {
  316. this.multipleSelection = val;
  317. },
  318. handleSizeChange(val) {
  319. this.limit = val;
  320. this.GetWarehouse();
  321. },
  322. handleCurrentChange(val) {
  323. this.page = val;
  324. this.GetWarehouse();
  325. },
  326. startTimeChange(val) {
  327. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  328. console.log("time是-----", time);
  329. if (time > 0) {
  330. this.$message.error("结束时间不能小于开始时间");
  331. this.start_time = "";
  332. } else {
  333. this.GetWarehouse();
  334. }
  335. },
  336. endTimeChange(val) {
  337. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  338. if (time < 0) {
  339. this.$message.error("结束时间不能小于开始时间");
  340. this.end_time = "";
  341. } else {
  342. this.GetWarehouse();
  343. }
  344. },
  345. getTimestamp(time) {
  346. // 把时间日期转成时间戳
  347. return new Date(time).getTime() / 1000;
  348. },
  349. calculate: function(val) {
  350. return Math.round(parseFloat(val) * 100) / 100;
  351. },
  352. GetConfigInfo: function() {
  353. GetAllConfig().then(response => {
  354. if (response.data.state == 0) {
  355. this.$message.error(response.data.msg);
  356. return false;
  357. } else {
  358. this.manufacturer = response.data.data.manufacturer;
  359. this.dealer = response.data.data.dealer;
  360. this.goodInfo = response.data.data.goodInfo;
  361. }
  362. });
  363. },
  364. getManufactuerName: function(manufacturer_id) {
  365. for (let i = 0; i < this.manufacturer.length; i++) {
  366. if (this.manufacturer[i].id == manufacturer_id) {
  367. return this.manufacturer[i].manufacturer_name;
  368. }
  369. }
  370. },
  371. getDealerName: function(dealer_id) {
  372. for (let i = 0; i < this.dealer.length; i++) {
  373. if (this.dealer[i].id == dealer_id) {
  374. return this.dealer[i].dealer_name;
  375. }
  376. }
  377. },
  378. handleEdit: function(index, row) {
  379. this.$router.push({
  380. name: "cancelStockDetail",
  381. query: { id: row.id, type: this.type }
  382. });
  383. },
  384. handleDelete: function(index, row) {
  385. const ids = [];
  386. ids.push(row.id);
  387. const idStr = ids.join(",");
  388. const params = {
  389. ids: idStr
  390. };
  391. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  392. confirmButtonText: "确定",
  393. cancelButtonText: "取消",
  394. type: "warning"
  395. })
  396. .then(() => {
  397. deleteCancelStock(params).then(response => {
  398. if (response.data.state == 0) {
  399. this.$message.error(response.data.msg);
  400. return false;
  401. } else {
  402. this.$notify({
  403. title: "成功",
  404. message: "删除成功",
  405. type: "success",
  406. duration: 2000
  407. });
  408. for (let i = 0; i < ids.length; i++) {
  409. for (let y = 0; y < this.cancelStockDate.length; y++) {
  410. if (ids[i] == this.cancelStockDate[y].id) {
  411. this.cancelStockDate.splice(y, 1);
  412. }
  413. }
  414. }
  415. }
  416. });
  417. })
  418. .catch(() => {});
  419. },
  420. changeAllSelected: function(val) {
  421. if (val) {
  422. this.$refs.multipleTable.toggleAllSelection();
  423. } else {
  424. this.$refs.multipleTable.clearSelection();
  425. }
  426. },
  427. select(selection) {
  428. this.selectedTableData = selection;
  429. },
  430. batchDelete() {
  431. if (this.selectedTableData.length <= 0) {
  432. this.$message.error("请选择要删除的记录");
  433. return;
  434. }
  435. const ids = [];
  436. for (let i = 0; i < this.selectedTableData.length; i++) {
  437. ids.push(this.selectedTableData[i].id);
  438. }
  439. const idStr = ids.join(",");
  440. const params = {
  441. ids: idStr
  442. };
  443. this.$confirm("确认删除出库退库单记录?", "删除出库退库单记录", {
  444. confirmButtonText: "确定",
  445. cancelButtonText: "取消",
  446. type: "warning"
  447. })
  448. .then(() => {
  449. deleteCancelStock(params).then(response => {
  450. if (response.data.state == 0) {
  451. this.$message.error(response.data.msg);
  452. return false;
  453. } else {
  454. this.$notify({
  455. title: "成功",
  456. message: "删除成功",
  457. type: "success",
  458. duration: 2000
  459. });
  460. for (let i = 0; i < ids.length; i++) {
  461. for (let y = 0; y < this.cancelStockDate.length; y++) {
  462. if (ids[i] == this.cancelStockDate[y].id) {
  463. this.cancelStockDate.splice(y, 1);
  464. }
  465. }
  466. }
  467. }
  468. });
  469. })
  470. .catch(() => {});
  471. }
  472. }
  473. };
  474. </script>
  475. <style rel="stylesheet/css" lang="scss" scoped>
  476. .information {
  477. border: 1px #dcdfe6 solid;
  478. padding: 30px 20px 30px 20px;
  479. .border {
  480. border-bottom: 1px #dcdfe6 solid;
  481. margin: 0px 0 20px 0;
  482. }
  483. }
  484. .edit_separater {
  485. border-top: 1px solid rgb(233, 233, 233);
  486. margin-top: 15px;
  487. margin-bottom: 15px;
  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. </style>