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

inventory.vue 19KB

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