Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

inventory.vue 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <div>
  3. <div v-show="showSearch">
  4. <label class="title"><span class="name">仓库</span> :</label>
  5. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px" @change="changeHouseList">
  6. <el-option
  7. v-for="(option, index) in houseList"
  8. :key="index"
  9. :label="option.storehouse_name"
  10. :value="option.id">
  11. </el-option>
  12. </el-select>
  13. <el-autocomplete
  14. class="checkSearch"
  15. popper-class="my-autocomplete"
  16. v-model="form.drug_name"
  17. :fetch-suggestions="querySearchAsync"
  18. :trigger-on-focus="true"
  19. placeholder="请输入耗材名称"
  20. @select="handleSelect"
  21. style="width:300px;"
  22. >
  23. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  24. <template slot-scope="{ item }">
  25. <div class="name">{{ item.good_name +" " +item.specification_name + " "+item.manufacturer }}</div>
  26. </template>
  27. </el-autocomplete>
  28. </div>
  29. <div v-show="showTable">
  30. <div>日期:{{nowTime}} 盘点人:{{user_name}}</div>
  31. <div style="float:right;margin-bottom:10px"><el-button type="primary" @click="saveInentoryList">保存</el-button></div>
  32. <el-collapse v-model="activeNames">
  33. <el-collapse-item :name="index" v-for="(item,index) in tableData" :key="index">
  34. <template slot="title">
  35. <div style="font-size:16px">{{item.good_name}}</div> &nbsp;&nbsp;{{item.specification_name}} <el-button type="warning" icon="el-icon-remove" style="margin-left:20px;" @click="toMove(item,index)">移除</el-button>
  36. </template>
  37. <el-table :data="item.child" border :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }" style="width:100%">
  38. <el-table-column prop="date" label="耗材名称" width="150" align="center">
  39. <template slot-scope="scope">
  40. {{scope.row.good_name}}
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="name" label="规格" width="100" align="center">
  44. <template slot-scope="scope">
  45. {{scope.row.specification_name}}
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="name" label="入库单号" width="100" align="center">
  49. <template slot-scope="scope">
  50. {{scope.row.warehousing_order}}
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="name" label="有效期" width="100" align="center">
  54. <template slot-scope="scope">
  55. {{getTime(scope.row.expiry_date)}}
  56. </template>
  57. </el-table-column>
  58. <el-table-column prop="name" label="批号" width="100" align="center">
  59. <template slot-scope="scope">
  60. {{scope.row.number}}
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="name" label="进货价" width="100" align="center">
  64. <template slot-scope="scope">
  65. {{scope.row.price}}
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="name" label="生产厂商" width="100" align="center">
  69. <template slot-scope="scope">
  70. {{scope.row.manufacturer_name}}
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="name" label="仓库名称" width="100" align="center">
  74. <template slot-scope="scope">
  75. {{getStorehouseName(scope.row.storehouse_id)}}
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="name" label="盘点前数量" width="120" align="center">
  79. <template slot-scope="scope">
  80. <span><el-input style="width:80px" v-model="scope.row.stock_count" :disabled="true"></el-input>{{scope.row.max_unit}}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="name" label="盘点后数量" width="120" align="center">
  84. <template slot-scope="scope">
  85. <el-input style="width:80px" v-model="scope.row.last_stock_count"></el-input>
  86. </template>
  87. </el-table-column>
  88. <el-table-column prop="name" label="盘点原因" width="180" align="center">
  89. <template slot-scope="scope">
  90. <el-select v-model="scope.row.type" placeholder="请选择">
  91. <el-option
  92. v-for="item in reasonList"
  93. :key="item.id"
  94. :label="item.name"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </template>
  99. </el-table-column>
  100. <el-table-column prop="name" width="200" align="center">
  101. <template slot-scope="scope">
  102. <span><el-button type="danger" @click="toDelete(scope.$index,scope.row.drug_id)">不盘点此批次</el-button></span>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </el-collapse-item>
  107. <label class="title"><span class="name">仓库</span>:</label>
  108. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px" @change="changeHouseList">
  109. <el-option
  110. v-for="(option, index) in houseList"
  111. :key="index"
  112. :label="option.storehouse_name"
  113. :value="option.id">
  114. </el-option>
  115. </el-select>
  116. <el-autocomplete
  117. class="checkSearch"
  118. popper-class="my-autocomplete"
  119. v-model="form.drug_name"
  120. :fetch-suggestions="querySearchAsync"
  121. :trigger-on-focus="true"
  122. placeholder="请输入耗材名称"
  123. @select="handleSelect"
  124. style="width:300px;"
  125. v-show="showTableOne"
  126. >
  127. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  128. <template slot-scope="{ item }">
  129. <div class="name">{{ item.good_name +" " +item.specification_name + " "+item.manufacturer }}</div>
  130. </template>
  131. </el-autocomplete>
  132. </el-collapse>
  133. </div>
  134. </div>
  135. </template>
  136. <script>
  137. const moment = require("moment");
  138. import { uParseTime } from '@/utils/tools'
  139. import { postSearchGoodWarehouseList,getInventoryList,SaveCheckedInventory,getInventoryDetail,deleteInventory,getWarehouseTotal,getGoodInventoryWarehouseList,saveStockInentoryList } from "@/api/stock"
  140. export default {
  141. name: "inventory",
  142. data() {
  143. return{
  144. user_name:this.$store.getters.xt_user.user.user_name,
  145. nowTime: moment(new Date()).format("YYYY-MM-DD HH:MM:SS"),
  146. searchKey:'',
  147. value1:'',
  148. value2:'',
  149. tableData: [],
  150. dialogVisible:false,
  151. total: 0,
  152. inventoryList:[
  153. {id:0,name:"全部"},
  154. {id:1,name:"盘点完成"},
  155. {id:2,name:"正在盘点"},
  156. ],
  157. start_time:"",
  158. end_time:"",
  159. form: {
  160. id:"",
  161. good_name: '',
  162. packing_price:'',
  163. new_price:"",
  164. count:"",
  165. remark:"",
  166. warehousing_order:"",
  167. manufacturer:"",
  168. dealer:"",
  169. license_number:"",
  170. warehousing_unit:"",
  171. specification_name:"",
  172. buy_price:"",
  173. good_id:"",
  174. packing_unit:"",
  175. good_origin_place:"",
  176. report_count:"",
  177. total:"",
  178. expiry_date:"",
  179. product_date:"",
  180. number:"",
  181. proof_count:"",
  182. storehouse_id:"",
  183. },
  184. manufacturerList:[],
  185. dealerList:[],
  186. goodList:[],
  187. currentIndex: 0,
  188. inventory_status:0,
  189. limit:10,
  190. page:1,
  191. doctorList:[],
  192. total:0,
  193. tableList:[],
  194. ids:"",
  195. checker:this.$store.getters.xt_user.user.id,
  196. check_time:new Date(),
  197. checkDialogVisible:false,
  198. editPriceDialogVisible:false,
  199. modefiyePriceDialogVisible:false,
  200. proofPriceDialogVisible:false,
  201. id:0,
  202. numberList:[],
  203. reasonList:[
  204. {id:6,name:"默认"},
  205. {id:1,name:"到期退货"},
  206. {id:2,name:"异常退货"},
  207. {id:3,name:"退货"},
  208. {id:4,name:"损坏"},
  209. {id:5,name:"不计入报损分析"},
  210. {id:7,name:"有效期到期"},
  211. ],
  212. activeNames: [0,1,2,3,4,5,6,7,8,9,10],
  213. showTable:false,
  214. showSearch:true,
  215. inventory_total:0,
  216. WarehouseList:[],
  217. showTableOne:false,
  218. houseList:[],
  219. storehouse_id:"",
  220. }
  221. },
  222. methods:{
  223. querySearchAsync(keyword, cb) {
  224. let key = '';
  225. if (keyword != undefined) {
  226. key = keyword
  227. }
  228. var params = {
  229. keyword:key,
  230. storehouse_id:this.storehouse_id,
  231. }
  232. postSearchGoodWarehouseList(params).then(response => {
  233. if (response.data.state == 1) {
  234. var list = response.data.data.list
  235. this.goodList = list
  236. var manufacturerList = response.data.data.manufacturerList
  237. this.manufacturerList = manufacturerList
  238. var dealer = response.data.data.dealerList
  239. this.dealerList = dealer
  240. for(let i=0;i<this.goodList.length;i++){
  241. for(let j=0;j<this.manufacturerList.length;j++){
  242. if(this.goodList[i].manufacturer == this.manufacturerList[j].id){
  243. this.goodList[i].manufacturer = this.manufacturerList[j].manufacturer_name
  244. }
  245. }
  246. }
  247. for(let i=0;i<this.goodList.length;i++){
  248. for(let j=0;j<this.dealerList.length;j++){
  249. if(this.goodList[i].dealer == this.dealerList[j].id){
  250. this.goodList[i].dealer = this.dealerList[j].dealer_name
  251. }
  252. }
  253. }
  254. cb(this.goodList)
  255. } else {
  256. cb([])
  257. }
  258. })
  259. },
  260. changeGoodName(val){
  261. this.currentIndex = val
  262. },
  263. handleSelect(val){
  264. this.getGoodInventoryWarehouseList(val.good_id)
  265. },
  266. search(){
  267. this.getlist()
  268. },
  269. print(){
  270. if(this.ids == ""){
  271. this.$message.error("请勾选打印数据")
  272. return
  273. }else{
  274. this.$router.push({path:'/stock/inventoryPrint?ids='+this.ids})
  275. }
  276. },
  277. getTime(val) {
  278. if(val < 0){
  279. return ""
  280. }
  281. if(val == ""){
  282. return ""
  283. }else {
  284. return uParseTime(val, '{y}-{m}-{d}')
  285. }
  286. },
  287. handleSizeChange(val){
  288. this.limit = val
  289. this.getlist()
  290. },
  291. handleCurrentChange(val){
  292. this.page = val
  293. this.getlist()
  294. },
  295. changeHouseList(){
  296. this.querySearchAsync()
  297. },
  298. getlist(){
  299. var params = {
  300. keyword:this.searchKey,
  301. start_time:this.start_time,
  302. end_time:this.end_time,
  303. inventory_status:this.inventory_status,
  304. page:this.page,
  305. limit:this.limit,
  306. }
  307. getInventoryList(params).then(response=>{
  308. if(response.data.state ==1 ){
  309. var list = response.data.data.list
  310. this.tableList = list
  311. var total = response.data.data.total
  312. this.total = total
  313. this.doctorList = response.data.data.doctorlist
  314. this.houseList = response.data.data.houseList
  315. console.log("仓库行吗32323232232332",this.houseList)
  316. var houseConfig = response.data.data.houseConfig
  317. this.storehouse_id = houseConfig.storehouse_out_info
  318. }
  319. })
  320. },
  321. getChecker(id){
  322. var name = ""
  323. for(let i=0;i<this.doctorList.length;i++){
  324. if(id == this.doctorList[i].admin_user_id){
  325. name = this.doctorList[i].user_name
  326. }
  327. }
  328. return name
  329. },
  330. toCheck(){
  331. if(this.ids.length <=0){
  332. this.$message.error("请勾选核对数据")
  333. return
  334. }else{
  335. this.checkDialogVisible = true
  336. }
  337. },
  338. changePrice(val){
  339. var arr = []
  340. for(let i=0;i<val.length;i++){
  341. arr.push(val[i].id)
  342. }
  343. var str = arr.join(",")
  344. this.ids = str
  345. },
  346. SaveCheckedInventory(){
  347. var params = {
  348. ids:this.ids,
  349. check_time:this.getTime(this.check_time),
  350. checker:this.checker,
  351. }
  352. SaveCheckedInventory(params).then(response=>{
  353. if(response.data.state == 1){
  354. this.$message.success("保存成功")
  355. var inventory = response.data.data.inventory
  356. this.checkDialogVisible = false
  357. this.getlist()
  358. }
  359. })
  360. },
  361. toDelete(index){
  362. this.tableData.splice(index,1)
  363. },
  364. getInventory(id){
  365. getInventoryDetail(id).then(response=>{
  366. if(response.data.state == 1){
  367. var detail = response.data.data.detail
  368. this.form.good_name = detail.good_name
  369. this.form.specification_name = detail.specification_name
  370. this.form.count = detail.count
  371. this.form.remark = detail.remark
  372. this.form.total = detail.total
  373. this.form.warehousing_info_id = detail.warehousing_info_id
  374. this.form.good_id = detail.good_id
  375. this.id = detail.id
  376. this.proofPriceDialogVisible = true
  377. }
  378. })
  379. },
  380. deleteInventory(id,check_status,index){
  381. if(check_status == 1){
  382. this.$message.error("已核对的不能编辑")
  383. return
  384. }
  385. this.$confirm('是否删除所选内容?', '提示', {
  386. confirmButtonText: '确定',
  387. cancelButtonText: '取消',
  388. type: 'warning'
  389. }).then(() => {
  390. deleteInventory(id).then(response => {
  391. if (response.data.state == 1) {
  392. var msg = response.data.data.msg
  393. this.$message.success("保存成功")
  394. this.tableList.splice(index,1)
  395. }
  396. })
  397. }).catch(() => {
  398. this.loading = false
  399. });
  400. },
  401. exportList(){
  402. import('@/vendor/Export2Excel').then(excel => {
  403. const tHeader = ['盘点编码', '盘点日期', '盘点数量','盘点人','审核日期','核对人','状态']
  404. const filterVal = ['warehousing_order', 'start_time', 'count','user_name','check_time','checker','checker_status']
  405. for(let i=0;i<this.tableList.length;i++){
  406. this.tableList[i].start_time = this.getTime(this.tableList[i].start_time)
  407. this.tableList[i].check_time = this.getTime(this.tableList[i].check_time)
  408. this.tableList[i].checker = this.getChecker(this.tableList[i].checker)
  409. if(this.tableList[i].checker_status == 1){
  410. this.tableList[i].checker_status = "已核对"
  411. }
  412. if(this.tableList[i].checker_status == 2){
  413. this.tableList[i].checker_status = "未核对"
  414. }
  415. }
  416. const data = this.formatJson(filterVal, this.tableList)
  417. excel.export_json_to_excel({
  418. header: tHeader,
  419. data,
  420. filename: '耗材盘点'
  421. })
  422. this.downloadLoading = false
  423. })
  424. },
  425. formatJson(filterVal, jsonData) {
  426. return jsonData.map(v => filterVal.map(j => v[j]));
  427. },
  428. getGoodInventoryWarehouseList(id){
  429. var params = {
  430. id:id,
  431. storehouse_id:this.storehouse_id,
  432. }
  433. getGoodInventoryWarehouseList(params).then(response=>{
  434. if(response.data.state == 1){
  435. var list = response.data.data.list
  436. for(let i=0;i<list.length;i++){
  437. list[i].type = 6
  438. list[i].good_name = list[i].GoodInfo.good_name
  439. list[i].specification_name = list[i].GoodInfo.specification_name
  440. list[i].manufacturer_name = ""
  441. for(let j=0;j<this.manufacturerList.length;j++){
  442. if(list[i].manufacturer == this.manufacturerList[j].id){
  443. list[i].manufacturer_name = this.manufacturerList[j].manufacturer_name
  444. }
  445. }
  446. this.WarehouseList.push(list[i])
  447. }
  448. let objInfo = {}
  449. this.WarehouseList.forEach((item,index)=>{
  450. let { good_id } = item
  451. if(!objInfo[good_id]){
  452. objInfo[good_id] = {
  453. good_id,
  454. child:[],
  455. good_name:item.good_name,
  456. specification_name:item.specification_name,
  457. warehouseing_unit:item.max_unit,
  458. price:item.price,
  459. number:item.number,
  460. expiry_date:item.expiry_date,
  461. type:0,
  462. last_stock_count:0,
  463. }
  464. }
  465. })
  466. let newList = Object.values(objInfo);
  467. for(let i=0;i<this.WarehouseList.length;i++){
  468. for(let j=0;j<newList.length;j++){
  469. if(this.WarehouseList[i].good_id == newList[j].good_id){
  470. newList[j].child.push(this.WarehouseList[i])
  471. }
  472. }
  473. }
  474. this.tableData = newList
  475. this.showSearch = false
  476. this.showTable = true
  477. if(this.tableData.length >=1){
  478. this.showTableOne = true
  479. }
  480. this.inventory_total = this.tableData.length
  481. }
  482. })
  483. },
  484. changeInventory(){
  485. this.getlist()
  486. },
  487. changeStartTime(val){
  488. this.start_time = this.getTime(val)
  489. this.getlist()
  490. },
  491. changeEndTime(val){
  492. this.end_time = this.getTime(val)
  493. this.getlist()
  494. },
  495. changeNumber(val){
  496. this.getWarehouseTotal(val)
  497. this.form.warehousing_info_id = val
  498. },
  499. getWarehouseTotal(id){
  500. var params = {
  501. id:id,
  502. }
  503. getWarehouseTotal(params).then(response=>{
  504. if(response.data.state == 1){
  505. var list = response.data.data.list
  506. this.form.total = list.stock_count
  507. }
  508. })
  509. },
  510. toMove(item,index){
  511. this.$confirm('此操作将移除耗材整个批次, 是否继续?', '提示', {
  512. confirmButtonText: '确定',
  513. cancelButtonText: '取消',
  514. type: 'warning'
  515. }).then(() => {
  516. this.tableData.splice(index,1)
  517. this.WarehouseList = []
  518. this.activeNames = [0,1,2,3,4,5,6,7,8,9,10]
  519. }).catch(() => {
  520. this.loading = false
  521. });
  522. },
  523. toDelete(index,drug_id){
  524. for(let i=0;i<this.tableData.length;i++){
  525. if(drug_id == this.tableData[i].drug_id){
  526. this.tableData[i].child.splice(index,1)
  527. if(this.tableData[i].child.length == 0){
  528. this.tableData.splice(index,1)
  529. }
  530. }
  531. }
  532. this.WarehouseList = []
  533. this.activeNames = [0,1,2,3,4,5,6,7,8,9,10]
  534. },
  535. saveInentoryList(){
  536. var arr = []
  537. for(let i=0;i<this.tableData.length;i++){
  538. for(let j=0;j<this.tableData[i].child.length;j++){
  539. arr.push(this.tableData[i].child[j])
  540. }
  541. }
  542. for(let i=0;i<arr.length;i++){
  543. if(arr[i].last_stock_count == undefined){
  544. arr[i].last_stock_count = 0
  545. }else{
  546. arr[i].last_stock_count = parseInt(arr[i].last_stock_count)
  547. }
  548. arr[i].storehouse_id = this.storehouse_id
  549. }
  550. var params = {
  551. tableData:arr,
  552. storehouse_id:this.storehouse_id,
  553. }
  554. console.log("param23323232323232323",params)
  555. saveStockInentoryList(params).then(response=>{
  556. if(response.data.state == 1){
  557. var inventory = response.data.data.inventory
  558. this.$message.success("保存成功")
  559. this.WarehouseList = []
  560. this.tableData = []
  561. }
  562. })
  563. },
  564. getStorehouseName(id){
  565. var storehouse_name = ""
  566. for(let i=0;i<this.houseList.length;i++){
  567. if(id == this.houseList[i].id){
  568. storehouse_name = this.houseList[i].storehouse_name
  569. }
  570. }
  571. return storehouse_name
  572. }
  573. },
  574. created(){
  575. this.getlist()
  576. },
  577. mounted() {
  578. },
  579. };
  580. </script>