transfer-lineEdge-edit.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="page">
  3. <uni-section title='单据信息' type='line' :strong="true" class="bg-white"/>
  4. <template v-if="type==='调出线边仓'">
  5. <view class="my-2 bg-white">
  6. <list-input title="调入仓库(名称)" class="bg-lightest">
  7. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='outCkIndex' :range='outCkList' range-key="CKMC" @change="onChangeCK('调出',$event)">
  8. <view v-if='outCkList.length>0'>
  9. {{outCkList[outCkIndex].CKMC}}
  10. </view>
  11. <view v-else>--</view>
  12. </picker>
  13. </list-input>
  14. <list-input title="调入库位(号)">
  15. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='outKwIndex' :range='outKwList' range-key="KWH" @change="onChangeKW('调出',$event)">
  16. <view v-if='outKwList.length>0'>
  17. {{outKwList[outKwIndex].KWH}}
  18. </view>
  19. <view v-else>--</view>
  20. </picker>
  21. </list-input>
  22. </view>
  23. <view class="my-2 bg-white">
  24. <list-input title="调出仓库(名称)">
  25. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='defaultCkIndex' :range='defaultCkList' range-key="CKMC" @change="onChangeCK('默认',$event)">
  26. <view v-if='defaultCkList.length > 0'>
  27. {{defaultCkList[defaultCkIndex].CKMC}}
  28. </view>
  29. <view v-else>--</view>
  30. </picker>
  31. </list-input>
  32. <list-input title="调出库位(号)">
  33. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='defaultKwIndex' :range='defaultKwList' range-key="KWH" @change="onChangeKW('默认',$event)">
  34. <view v-if='defaultKwList.length>0'>
  35. {{defaultKwList[defaultKwIndex].KWH}}
  36. </view>
  37. <view v-else>--</view>
  38. </picker>
  39. </list-input>
  40. </view>
  41. </template>
  42. <!-- 调入线边仓,调出是从我的仓库调出, -->
  43. <template v-if="type==='调入线边仓'">
  44. <view class="my-2 bg-white">
  45. <list-input title="调出仓库(名称)">
  46. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='defaultCkIndex' :range='defaultCkList' range-key="CKMC" @change="onChangeCK('默认',$event)">
  47. <view v-if='defaultCkList.length > 0'>
  48. {{defaultCkList[defaultCkIndex].CKMC}}
  49. </view>
  50. <view v-else>--</view>
  51. </picker>
  52. </list-input>
  53. <list-input title="调出库位(号)">
  54. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='defaultKwIndex' :range='defaultKwList' range-key="KWH" @change="onChangeKW('默认',$event)">
  55. <view v-if='defaultKwList.length>0'>
  56. {{defaultKwList[defaultKwIndex].KWH}}
  57. </view>
  58. <view v-else>--</view>
  59. </picker>
  60. </list-input>
  61. </view>
  62. <view class="my-2 bg-white">
  63. <list-input title="调入仓库(名称)">
  64. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='inCkIndex' :range='inCkList' range-key="CKMC" @change="onChangeCK('调入',$event)">
  65. <view v-if='inCkList.length > 0'>
  66. {{inCkList[inCkIndex].CKMC}}
  67. </view>
  68. <view v-else>--</view>
  69. </picker>
  70. </list-input>
  71. <list-input title="调入库位(号)">
  72. <picker class="height-100 text-right form-item-input flex align-center justify-end" :value='inKwIndex' :range='inKwList' range-key="KWH" @change="onChangeKW('调入',$event)">
  73. <view v-if='inKwList.length > 0'>
  74. {{inKwList[inKwIndex].KWH}}
  75. </view>
  76. <view v-else>--</view>
  77. </picker>
  78. </list-input>
  79. </view>
  80. </template>
  81. <table-list :list="list"></table-list>
  82. <btn-save :disabledOk="disabledSubmit || loading" @save='onSave' back/>
  83. </view>
  84. </template>
  85. <script>
  86. import uniSection from "@/components/uni-ui/uni-section/uni-section.vue"
  87. import listInput from "@/components/common/list-input.vue"
  88. import tableList from "@/components/common/table-list.vue"
  89. import btnSave from "@/components/common/btn-save.vue"
  90. import {queryInStorageLocation,queryOutStorageLocation,queryDefaultStorage} from "@/api/api.js"
  91. import {mapState,mapGetters} from "vuex"
  92. import {saveLinesidetransfer} from "@/api/api.js"
  93. export default {
  94. components:{
  95. uniSection,
  96. listInput,
  97. tableList,
  98. btnSave
  99. },
  100. data () {
  101. return {
  102. defaultKwIndex:0, // 默认库位索引
  103. defaultCkList:[], // 默认仓库列表
  104. defaultCkIndex:0, // 默认仓库索引
  105. inRealCkList:[], // 调入仓库(后台数据)
  106. inCkIndex:0, // 调入仓库索引
  107. inKwIndex:0, // 调入 库位 索引
  108. outRealCkList:[], // 调出仓库(后台数据)
  109. outCkIndex:0, // 调出
  110. outKwIndex:0, // 调出 库位 索引
  111. list:{ // 表格
  112. head:[
  113. {key:'itemno',dataIndex:"itemno",title:"物品号",},
  114. {key:'itemnum',dataIndex:"itemnum",title:"调拨数量",},
  115. ],
  116. body:[]
  117. },
  118. type:null ,// 调拨类型
  119. loading:false
  120. }
  121. },
  122. computed : {
  123. ...mapGetters(['disabledSubmit']),
  124. ...mapState(['ckList']),
  125. // 调入仓库
  126. inCkList () {
  127. return this._getLineCk()
  128. },
  129. // 调出仓库
  130. outCkList () {
  131. return this._getLineCk()
  132. },
  133. // 默认仓库库位
  134. defaultKwList () {
  135. if (this.defaultCkList.length > 0) {
  136. return this.defaultCkList[this.defaultCkIndex].storageloca
  137. }
  138. return []
  139. },
  140. // 调入 库位列表
  141. inKwList () {
  142. if (this.inCkList.length > 0) {
  143. return this.inCkList[this.inCkIndex].storageloca
  144. }
  145. return []
  146. },
  147. // 调出 库位列表
  148. outKwList () {
  149. if (this.outCkList.length > 0) {
  150. return this.outCkList[this.outCkIndex].storageloca
  151. }
  152. return []
  153. }
  154. },
  155. onLoad (e) {
  156. this.type=e.type
  157. let list=JSON.parse(e.list)
  158. this.list.body=list
  159. this.initPage()
  160. },
  161. onPageScroll(res) {
  162. uni.$emit('onPageScroll',res);
  163. },
  164. methods:{
  165. // 初始化页面
  166. async initPage () {
  167. this.loading=true
  168. await this._queryDefaultStorage()
  169. switch (this.type) {
  170. case "调入线边仓":
  171. await this._queryInStorageLocation()
  172. break;
  173. case "调出线边仓" :
  174. await this._queryOutStorageLocation()
  175. break;
  176. }
  177. this.loading=false
  178. uni.setNavigationBarTitle({
  179. title:this.type
  180. });
  181. },
  182. // 获取默认仓库
  183. async _queryDefaultStorage () {
  184. let resdata=await queryDefaultStorage()
  185. this.defaultCkList=resdata
  186. return this.defaultCkList
  187. },
  188. // 依据仓库获取线边仓
  189. _getLineCk () {
  190. let arr=[]
  191. const realArr=this.type==='调入线边仓' ? 'inRealCkList' : 'outRealCkList'
  192. if (this.defaultCkList.length>0) {
  193. const BMH=this.defaultCkList[this.defaultCkIndex].BMH
  194. arr=this[realArr].filter(item=>{
  195. return item.BMH===BMH
  196. })
  197. }
  198. return arr
  199. },
  200. // 改变仓库
  201. onChangeCK (key,event) {
  202. const index=event.detail.value
  203. switch (key) {
  204. case "调入" :
  205. this.inCkIndex=index
  206. break;
  207. case "调出" :
  208. this.outCkIndex=index
  209. break;
  210. case "默认" :
  211. this.defaultCkIndex=index
  212. break;
  213. }
  214. },
  215. // 改变库位
  216. onChangeKW (key,event) {
  217. const index=event.detail.value
  218. switch (key) {
  219. case "调入" :
  220. this.inKwIndex=index
  221. break;
  222. case "调出" :
  223. this.outKwIndex=index
  224. break;
  225. case "默认" :
  226. this.defaultKwIndex=index
  227. break;
  228. }
  229. },
  230. //查询 调出仓库信息
  231. async _queryOutStorageLocation () {
  232. const resdata=await queryOutStorageLocation()
  233. this.outRealCkList=resdata
  234. return resdata
  235. },
  236. // 查询 调入仓库信息
  237. async _queryInStorageLocation () {
  238. const resdata=await queryInStorageLocation()
  239. this.inRealCkList=resdata
  240. return resdata
  241. },
  242. // 保存接口
  243. async _saveLinesidetransfer () {
  244. let type=-1,
  245. outCkh=this.defaultCkList[this.defaultCkIndex].CKH,
  246. outKwh=this.defaultKwList[this.defaultKwIndex].KWH,
  247. inCkh=null,
  248. inKwh=null,
  249. items=[];
  250. switch (this.type) {
  251. case "调入线边仓":
  252. type=1 ;
  253. inCkh=this.inCkList[this.inCkIndex].CKH ;
  254. inKwh=this.inKwList[this.inKwIndex].KWH ;
  255. break;
  256. case "调出线边仓" :
  257. type=0 ;
  258. inCkh=this.outCkList[this.outCkIndex].CKH ;
  259. inKwh=this.outKwList[this.outKwIndex].KWH ;
  260. break;
  261. }
  262. this.list.body.forEach(item=>{
  263. items.push({"WPH":item.itemno,"SL":item.itemnum})
  264. })
  265. const reqdata={
  266. "CKHOUT":outCkh, //调出仓库
  267. "KWHOUT":outKwh, //调出库位号
  268. "CKHIN":inCkh, //调入仓库
  269. "KWHIN":inKwh, //调入库位号
  270. "TYPE":type, // 0为调出,1为调入
  271. "items":items
  272. }
  273. const resdata=await saveLinesidetransfer(reqdata)
  274. return resdata
  275. },
  276. onSave () {
  277. uni.showModal({
  278. title:"确认保存吗?",
  279. success:async (res)=>{
  280. if (res.confirm) {
  281. await this._saveLinesidetransfer()
  282. uni.showToast({
  283. title:"保存成功"
  284. })
  285. uni.reLaunch({
  286. url:"/pages/index/index"
  287. })
  288. }
  289. }
  290. })
  291. }
  292. }
  293. }
  294. </script>
  295. <style>
  296. </style>