newInventory.vue 16KB

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