warehouseLocation.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div>
  3. <en-table-layout :tableData="tableData" :loading="loading" @selection-change="handleSelectionChange">
  4. <div slot="toolbar" class="inner-toolbar">
  5. <div class="toolbar-btns">
  6. <el-button size="mini" v-if="checkPermission(['goodsLend:add'])" type="primary"
  7. @click="handleAddGoodsLend">新增</el-button>
  8. </div>
  9. <div class="toolbar-search">
  10. </div>
  11. </div>
  12. <template slot="table-columns">
  13. <el-table-column type="selection" width="55" />
  14. <el-table-column prop="name" label="名称">
  15. </el-table-column>
  16. <el-table-column prop="remark" label="备注">
  17. </el-table-column>
  18. <el-table-column label="操作" width="250">
  19. <template slot-scope="scope">
  20. <el-button size="mini" v-if="checkPermission(['goodsLend:edit'])"
  21. @click="handleEditGoodsLend(scope.row)">编辑</el-button>
  22. <el-button type="success" size="mini"
  23. v-if="checkPermission(['goodsLend:del'])"
  24. @click="handleReturnGoodsLend(scope.row)">删除</el-button>
  25. </template>
  26. </el-table-column>
  27. </template>
  28. <!-- <el-pagination v-if="tableData" slot="pagination" @size-change="handlePageSizeChange"
  29. @current-change="handlePageCurrentChange" :current-page="tableData.page_no" :page-sizes="[10, 20, 50, 100]"
  30. :page-size="tableData.page_size" layout="total, sizes, prev, pager, next, jumper" :total="tableData.data_total">
  31. </el-pagination> -->
  32. </en-table-layout>
  33. <el-dialog :title="title" :visible.sync="dialogVisibleForm" width="940px" center @close='addHandleCancle'>
  34. <el-form ref="addLendForm" :model="addLendForm" :rules="rules" label-width="90px">
  35. <el-form-item label="编号" prop="code">
  36. <el-input
  37. placeholder="请输入编号"
  38. v-model="addLendForm.code">
  39. </el-input>
  40. </el-form-item>
  41. <el-form-item label="名称" prop="name">
  42. <el-input
  43. placeholder="请输入名称"
  44. v-model="addLendForm.name">
  45. </el-input>
  46. </el-form-item>
  47. <el-form-item label="备注">
  48. <el-input
  49. type="textarea"
  50. :autosize="{ minRows: 2, maxRows: 4}"
  51. placeholder="请输入内容"
  52. v-model="addLendForm.remark">
  53. </el-input>
  54. </el-form-item>
  55. </el-form>
  56. <span slot="footer" class="dialog-footer">
  57. <el-button @click="addHandleCancle ">取 消</el-button>
  58. <el-button type="primary" @click="lendCommit">确 定</el-button>
  59. </span>
  60. </el-dialog>
  61. </div>
  62. </template>
  63. <script>
  64. import * as API_GoodsLend from '@/api/goodsLend'
  65. import Print from 'print-js'
  66. import * as API_Setting from '@/api/setting'
  67. import { Foundation } from '~/ui-utils'
  68. import QRCode from 'qrcodejs2'
  69. export default {
  70. name: 'goodsLend',
  71. data() {
  72. return {
  73. warehouseSn:"",
  74. warehouseList: [],
  75. // 列表loading状态
  76. loading: false,
  77. // 列表参数
  78. params: {
  79. page_no: 1,
  80. page_size: 10
  81. },
  82. // 高级搜索数据
  83. advancedForm: {},
  84. // 列表数据
  85. tableData: '',
  86. dialogVisible: false,
  87. // 当前已选择的行
  88. multipleSelection: [],
  89. goodsLendForm: {},
  90. codeList:[],
  91. title:"",
  92. dialogVisibleForm:false,
  93. // 新增数据
  94. addLendForm:{
  95. name:"",
  96. remark:""
  97. },
  98. rules: {
  99. name: [
  100. { required: true, message: '请选择输入名称', trigger: 'blur' }
  101. ],
  102. code:[
  103. { required: true, message: '请选择输入编号', trigger: 'blur' }
  104. ]
  105. },
  106. typeList:[],
  107. id:''
  108. }
  109. },
  110. mounted() {
  111. this.GET_GoodsLendList()
  112. this.GET_DeptList()
  113. },
  114. watch: {
  115. $route: {
  116. immediate: true,
  117. handler(newVal) {
  118. if (newVal.query.status) {
  119. this.params.status = newVal.query.status
  120. this.advancedForm.status = newVal.query.status
  121. }
  122. this.params.page_no = 1
  123. this.GET_GoodsLendList()
  124. }
  125. }
  126. },
  127. methods: {
  128. ceshi(){
  129. this.$router.push({name:"demo"})
  130. },
  131. gowareHouse(){
  132. this.dialogVisibleForm=false
  133. this.$router.push({ name: 'warehouseList'})
  134. },
  135. /* 选中仓库 */
  136. selWarehouse(val){
  137. const list=this.warehouseList.filter(el=>{
  138. return el.id===val
  139. })
  140. let obj = list[0]
  141. this.warehouseSn=obj.sn
  142. },
  143. // 确认提交
  144. lendCommit(){
  145. this.$refs.addLendForm.validate((valid) => {
  146. if (valid) {
  147. if(this.title==='新增'){
  148. this.addLendForm.code=this.warehouseSn+"-"+this.addLendForm.code
  149. API_GoodsLend.addCreateAreaType(this.addLendForm).then(res=>{
  150. this.$message.success('添加成功!')
  151. this.dialogVisibleForm=false
  152. this.warehouseSn=""
  153. this.addLendForm={}
  154. this.GET_GoodsLendList()
  155. })
  156. }else if(this.title==='编辑'){
  157. API_GoodsLend.editUpdateAreaType(this.id,this.addLendForm).then(res=>{
  158. this.$message.success('修改成功!')
  159. this.dialogVisibleForm=false
  160. this.id=''
  161. this.addLendForm={}
  162. this.GET_GoodsLendList()
  163. })
  164. }
  165. } else {
  166. this.$message.error('提交失败')
  167. return false;
  168. }
  169. })
  170. },
  171. addHandleCancle(){
  172. this.dialogVisibleForm=false
  173. this.addLendForm={}
  174. },
  175. handleCancle () {
  176. this.dialogVisible = false
  177. this.codeList=[]
  178. },
  179. // 二维码生成
  180. creatQrCode() {
  181. this.$nextTick(() => {
  182. this.codeList.forEach((item,index)=>{
  183. this.$refs.codeItem[index].innerHTML="";
  184. var qrcode = new QRCode(this.$refs.codeItem[index], {
  185. text: item, //二维码内容
  186. width: 600,
  187. height: 660,
  188. render: 'table',
  189. colorDark: "#333333", //二维码颜色
  190. colorLight: "#ffffff", //二维码背景色
  191. correctLevel : QRCode.CorrectLevel.H
  192. })
  193. });
  194. },500)
  195. },
  196. handleEditGoodsLend(row) {
  197. this.id=row.id
  198. this.title="编辑"
  199. this.addLendForm=row
  200. this.dialogVisibleForm=true
  201. // this.$router.push({ name: 'goodsLendEdit', params: { id: row.id }})
  202. },
  203. handleReturnGoodsLend(row) {
  204. this.$confirm('确定要删除吗?', '提示', { type: 'warning' }).then(() => {
  205. API_GoodsLend.removeAreaType(row.id).then(() => {
  206. this.$message.success('删除成功!')
  207. this.GET_GoodsLendList()
  208. })
  209. }).catch(() => { })
  210. },
  211. /** 状态 */
  212. statusFilter(val) {
  213. const obj=this.typeList.filter(el=>{
  214. return el.value===val
  215. })
  216. if(obj.length !== 0){
  217. return obj[0].label
  218. }else{
  219. return ""
  220. }
  221. },
  222. handleConfirmGoodsLend() {
  223. if (!this.multipleSelection || !this.multipleSelection.length) return this.$message.error('请先选择!')
  224. const ids = this.multipleSelection.map(item => item.code)
  225. this.codeList=ids
  226. this.dialogVisible = true
  227. this.creatQrCode()
  228. },
  229. /** 获取部门 */
  230. GET_DeptList() {
  231. API_Setting.getListAll().then(response => {
  232. this.warehouseList = response
  233. console.log(response);
  234. })
  235. API_Setting.getPage({dictType:"Warehouse_location_type",page_no: 1,page_size: 50}).then(res=>{
  236. this.typeList=res.data
  237. })
  238. },
  239. /** 打印对账详情 */
  240. handlePrintGoodsLend() {
  241. Print({
  242. printable: 'deliverySheet',
  243. type: 'html',
  244. targetStyles: ['*'],
  245. //style: 'body, html {font-size:300px !important;color:red;}', // 确保打印时应用这个样式
  246. ignoreElements: ['no-logs', 'goods-image', 'no-btn','elementToIgnore']
  247. })
  248. },
  249. handleDeleteGoodsLend() {
  250. if (!this.multipleSelection || !this.multipleSelection.length) return this.$message.error('请先选择!')
  251. this.$confirm('确定要删除这些借出单吗?', '提示', { type: 'warning' }).then(() => {
  252. const ids = this.multipleSelection.map(item => item.id)
  253. API_GoodsLend.deleteGoodsLend(ids).then(() => {
  254. this.$message.success('删除成功!')
  255. this.GET_GoodsLendList()
  256. })
  257. }).catch(() => { })
  258. },
  259. /** 多选改变 */
  260. handleSelectionChange(val) {
  261. this.multipleSelection = val
  262. },
  263. /** 分页大小发生改变 */
  264. handlePageSizeChange(size) {
  265. this.params.page_size = size
  266. this.GET_GoodsLendList()
  267. },
  268. /** 分页页数发生改变 */
  269. handlePageCurrentChange(page) {
  270. this.params.page_no = page
  271. this.GET_GoodsLendList()
  272. },
  273. /** 添加调整单 */
  274. handleAddGoodsLend() {
  275. this.title="新增"
  276. this.dialogVisibleForm=true
  277. // this.$router.push({ name: 'goodsLendAdd'})
  278. },
  279. /** 打印调整单 */
  280. handlePrintGoodsLendDialog(row) {
  281. // this.GET_GoodsLendDetail(row.id)
  282. this.dialogVisible = true
  283. this.codeList.push(row.code)
  284. this.creatQrCode()
  285. },
  286. /** 获取调整单详情页面数据 */
  287. GET_GoodsLendDetail(id) {
  288. API_GoodsLend.getGoodsLendInfo(id).then(response => {
  289. this.goodsLendForm = response
  290. if (response.product_list && response.product_list.length) {
  291. var str = ''
  292. response.product_list.forEach(function(i) {
  293. str += i.product_name + '、'
  294. })
  295. }
  296. // 生成库位号二维码
  297. this.goodsLendForm.illustrate = str
  298. })
  299. },
  300. /** 搜索事件触发 */
  301. searchEvent(data) {
  302. this.params = {
  303. ...this.params,
  304. sn: data
  305. }
  306. Object.keys(this.advancedForm).forEach((key) => delete this.params[key])
  307. this.params.page_no = 1
  308. this.GET_GoodsLendList()
  309. },
  310. /** 高级搜索事件触发 */
  311. advancedSearchEvent() {
  312. this.params = {
  313. ...this.params,
  314. ...this.advancedForm
  315. }
  316. delete this.params.start_time
  317. delete this.params.end_time
  318. if (this.advancedForm.goodsLend_time_range) {
  319. this.params.start_time = parseInt(Number(this.advancedForm.goodsLend_time_range[0]) / 1000)
  320. this.params.end_time = parseInt(Number(this.advancedForm.goodsLend_time_range[1]) / 1000)
  321. }
  322. delete this.params.goodsLend_time_range
  323. this.params.page_no = 1
  324. this.GET_GoodsLendList()
  325. },
  326. /** 获取库存区域列表 */
  327. GET_GoodsLendList() {
  328. this.loading = true
  329. API_GoodsLend.getListAreaType().then(response => {
  330. this.loading = false
  331. this.tableData = response
  332. }).catch(() => { this.loading = false })
  333. }
  334. }
  335. }
  336. </script>
  337. <style type="text/scss" lang="scss" scoped>
  338. .print {
  339. margin-left: 790px;
  340. }
  341. .tips-t {
  342. display: flex;
  343. padding: 10px 0;
  344. div {
  345. flex: 1;
  346. display: flex;
  347. justify-content: center;
  348. align-items: center;
  349. flex-direction: column;
  350. }
  351. }
  352. .tips-f {
  353. padding: 20px 0;
  354. }
  355. .face-image {
  356. display: block;
  357. width: 50px;
  358. height: 50px;
  359. margin: 0 auto;
  360. }
  361. /* /deep/ .el-dialog__body {
  362. padding: 10px 20px;
  363. }
  364. /deep/.el-form{
  365. .el-form-item__content{
  366. display: flex;
  367. }
  368. } */
  369. /* @media print {
  370. html, body {
  371. font-size: 60pt !important;
  372. color: red;
  373. }
  374. } */
  375. </style>