outsource-reveive-list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="page">
  3. <uni-section type='line' :title='pageTitle' class="bg-white my-2"></uni-section>
  4. <template v-if="showChoosedList">
  5. <!-- 选择的数据 -->
  6. <view class="bg-white p-2">
  7. <!-- 自仓库号 自库位号,至 仓库号至于库位号 -->
  8. <view class="flex align-center font-mmd">
  9. <picker class="border rounded width-100 mx-1" :value='toCkIndex' :range='toCkList' range-key="CKMC" :disabled="disabledStorage" :class="disabledStorage?'bg-light':''" @change="onChangeCk('至',$event)">
  10. <view v-if='toCkList.length>0 && !disabledStorage' class="form-item-input">
  11. {{toCkList[toCkIndex].CKMC}}
  12. </view>
  13. <view v-else class="form-item-input text-muted">仓库号</view>
  14. </picker>
  15. <picker class="border rounded width-100 ml-1" :value='toKwIndex' :range='toKwList' range-key="KWH" :disabled="disabledStorage" :class="disabledStorage?'bg-light':''" @change="onChangeKw('至',$event)">
  16. <view v-if='toKwList.length>0 && !disabledStorage' class="form-item-input ">
  17. {{toKwList[toKwIndex].KWH}}
  18. </view>
  19. <view v-else class="form-item-input text-muted">库位号</view>
  20. </picker>
  21. </view>
  22. </view>
  23. <view v-for="(item,index) in choosedList" class="my-1 flex width-100 align-center">
  24. <view class="flex-1 position-relative">
  25. <view v-if="item.active" class="position-absolute top-0 right-0 pic-yd-box">
  26. <image src="@/static/images/yidu1.png" mode="" class="pic-yd"></image>
  27. </view>
  28. <list-item style="margin:0" :class="item.active ? 'list-item-active' : ''">
  29. <receive-item :item="item" :index="index" class="flex-1">
  30. <item-row title="数量" :span='6'>
  31. <view class="flex align-center border">
  32. <view class="flex-1">
  33. <input type="text" v-model="item.amount" :data-index="index" :data-item="item" @input="onInputAmount(index,$event)" @blur='onBlurAmount(index,$event)'/>
  34. </view>
  35. <view class="flex-shrink" v-show="item.amount">
  36. <view class="iconfont icon-shanchu4" @tap="onClearAmount(index)"></view>
  37. </view>
  38. </view>
  39. </item-row>
  40. </receive-item>
  41. </list-item>
  42. </view>
  43. <view class="flex-shrink pl-1">
  44. <!-- <view
  45. class="iconfont icon-qingkong form-item-icon border text-danger rounded-circle"
  46. @tap="onRemoveItem(index)"></view> -->
  47. <!-- </view> -->
  48. </view>
  49. </view>
  50. <btn-save @save="onSubmit" :disabledOk="disabledSubmit" @cancel="onCancelChoosed" customCancel></btn-save>
  51. </template>
  52. <template v-else>
  53. <!-- 全部数据 -->
  54. <checkbox-group @change="onChangeCheckbox" v-if="list.length > 0">
  55. <view v-for="(item,index) in list" class="my-1 flex width-100 align-center">
  56. <view class="flex-1 " @tap.stop>
  57. <list-item >
  58. <receive-item :item="item"/>
  59. </list-item>
  60. </view>
  61. <view class="flex-shrink pl-1">
  62. <checkbox :value="item.HH" :checked="item.checked" />
  63. </view>
  64. </view>
  65. </checkbox-group>
  66. <template v-else>
  67. <nothing />
  68. </template>
  69. <btn-save @save="onSaveList" okText='确认' @cancel="onCancelCheckbox" customCancel :disabledOk="listDisabledOk"></btn-save>
  70. </template>
  71. </view>
  72. </template>
  73. <script>
  74. import uniSection from "@/components/uni-ui/uni-section/uni-section.vue"
  75. import listItem from "@/components/warehousing-list/list-item.vue"
  76. import btnSave from "@/components/common/btn-save.vue"
  77. import receiveItem from "@/components/outsource-receive-list/list-item.vue"
  78. import itemRow from "@/components/common/item-row.vue"
  79. import {
  80. formateScanData
  81. } from "@/common/utils/common.js"
  82. import {amount} from "@/common/utils/reg.js"
  83. import {
  84. TEXT_CPWW,
  85. TEXT_GXWW
  86. } from "@/common/utils/types.js"
  87. import {
  88. queryreciveCommissionwarehouse,
  89. queryrecivebodyCommissionwarehouse,
  90. queryReciveStorageLocation,
  91. saveIncommissionwarehouse
  92. } from "@/api/api.js"
  93. export default {
  94. components: {
  95. uniSection,
  96. listItem,
  97. btnSave,
  98. receiveItem,
  99. itemRow
  100. },
  101. data() {
  102. return {
  103. showChoosedList:false, // 展示选择的数据
  104. barcode: null, // 条形码
  105. list: [], // 全部数据
  106. choosedList: [], // 选择的数据
  107. DDH: null, // 委外订单号
  108. detail: {}, // 单据号详情
  109. choosedValue: [], // 选择的数据
  110. toCkList: [], // 至仓库列表
  111. toCkIndex: 0, // 至仓库索引
  112. toKwIndex: 0, // 至 库位索引
  113. disabledSubmit: false, // 禁用提交
  114. }
  115. },
  116. computed:{
  117. // 页面表题
  118. pageTitle() {
  119. const type = this.detail.LXSM ? this.detail.LXSM : ""
  120. const ddh = this.DDH ? this.DDH : ""
  121. return `${type}:${ddh}`
  122. },
  123. // 禁止选择仓库
  124. disabledStorage () {
  125. let x=false
  126. switch (this.detail.LXSM) {
  127. case TEXT_GXWW:
  128. x=true
  129. break;
  130. }
  131. return x
  132. },
  133. // 选择列表:是否允许点击确认
  134. listDisabledOk() {
  135. return this.choosedValue.length <= 0
  136. },
  137. // 至库位列表
  138. toKwList() {
  139. let arr = []
  140. if (this.toCkList.length > 0) {
  141. return this.toCkList[this.toCkIndex].storageloca
  142. }
  143. return arr
  144. },
  145. },
  146. onLoad(e) {
  147. this.barcode = e.barcode
  148. const {
  149. orderno
  150. } = formateScanData(this.barcode)
  151. this.DDH = orderno
  152. this.initPage()
  153. },
  154. onBackPress(e) {
  155. if (this.showChoosedList) {
  156. this._formatCancelChoosedList()
  157. return true
  158. }else{
  159. const from=e.from
  160. if (from === 'navigateBack') {
  161. return false;
  162. }
  163. this.confirmLeavePage()
  164. return true;
  165. }
  166. },
  167. methods: {
  168. // 初始化页面
  169. async initPage() {
  170. await this._queryreciveCommissionwarehouse()
  171. await this._queryrecivebodyCommissionwarehouse()
  172. },
  173. // 返回页面
  174. onCancelCheckbox () {
  175. this.confirmLeavePage()
  176. },
  177. // 确定离开页面
  178. confirmLeavePage () {
  179. if (this.choosedList.length <=0) {
  180. uni.navigateBack({
  181. delta: 1
  182. })
  183. }else {
  184. uni.showModal({
  185. title: "重要提示",
  186. content: "您还未保存提交数据,离开将清空数据,确定离开吗?",
  187. success: (res) => {
  188. if (res.confirm) {
  189. uni.navigateBack({
  190. delta: 1
  191. })
  192. }
  193. }
  194. })
  195. return true
  196. }
  197. },
  198. // 获取全部数据
  199. async _queryreciveCommissionwarehouse() {
  200. const reqdata = {
  201. DDH: this.DDH
  202. }
  203. const resdata = await queryreciveCommissionwarehouse(reqdata)
  204. this.detail = resdata[0]
  205. },
  206. // 获取明细
  207. async _queryrecivebodyCommissionwarehouse() {
  208. const reqdata = {
  209. DDH: this.DDH
  210. }
  211. const resdata = await queryrecivebodyCommissionwarehouse(reqdata)
  212. resdata.forEach(item=>{
  213. item.checked=false
  214. item.amount=null
  215. item.active=false
  216. this.list.push(item)
  217. })
  218. },
  219. // 选择多选框
  220. onChangeCheckbox(e) {
  221. const value=e.detail.value
  222. this.choosedValue = value
  223. this.list.forEach((item,index,array)=>{
  224. const i=value.indexOf(item.HH)
  225. if (i>=0){
  226. item.checked=true
  227. }else{
  228. item.checked=false
  229. }
  230. })
  231. },
  232. // 改变库位
  233. onChangeKw(key, event) {
  234. const index = event.detail.value
  235. switch (key) {
  236. case "至":
  237. this.toKwIndex = index
  238. break;
  239. }
  240. },
  241. // 改变仓库
  242. onChangeCk(key, event) {
  243. const index = event.detail.value
  244. switch (key) {
  245. case "至":
  246. this.toCkIndex = index
  247. break;
  248. }
  249. },
  250. // 查询至仓库
  251. async _queryReciveStorageLocation() {
  252. const resdata=await queryReciveStorageLocation()
  253. this.toCkList = resdata
  254. return this.toCkList
  255. },
  256. // 保存选择的列表
  257. async onSaveList() {
  258. this.showChoosedList = true
  259. this.choosedList=this.list.filter(item=>{
  260. return item.checked
  261. })
  262. if (this.detail.LXSM===TEXT_CPWW) {
  263. this.disabledSubmit=true
  264. await this._queryReciveStorageLocation()
  265. this.disabledSubmit=false
  266. }
  267. },
  268. // 清空某一项
  269. onClearAmount (index) {
  270. uni.showModal({
  271. title:"确定清空该数据吗",
  272. success:res=>{
  273. if (res.confirm) {
  274. this.choosedList[index].amount=null
  275. this.choosedList[index].active=false
  276. }
  277. }
  278. })
  279. },
  280. // 输入数量
  281. onInputAmount(index,event) {
  282. const item=this.choosedList[index]
  283. if (!amount.test(item.amount)) {
  284. return uni.showToast({
  285. title:"请输入准确的数字",
  286. icon:"none"
  287. })
  288. }else{
  289. this.choosedList[index].active=true
  290. }
  291. },
  292. // 离开数量焦点
  293. onBlurAmount (index,event) {
  294. const item=this.choosedList[index]
  295. if (!amount.test(item.amount)) {
  296. this.choosedList[index].amount=null
  297. this.choosedList[index].active=false
  298. return uni.showToast({
  299. title:"输入内容不是数字",
  300. icon:"none"
  301. })
  302. }else{
  303. this.choosedList[index].active=true
  304. }
  305. },
  306. // 提交
  307. onSubmit() {
  308. let ok = true
  309. let msg = ""
  310. if (this.detail.LXSM===TEXT_CPWW) {
  311. if (!this.toCkList[this.toCkIndex].CKH) {
  312. ok = false
  313. msg = "请选择至仓库名称"
  314. } else if (!this.toKwList[this.toKwIndex].KWH) {
  315. ok = false
  316. msg = "请选择至库位号"
  317. }
  318. }
  319. this.choosedList.forEach(item=>{
  320. if (!item.amount) {
  321. ok = false
  322. msg = "请输入数量"
  323. }else if (!amount.test(item.amount)) {
  324. ok=false
  325. msg="请输入准确的数字"
  326. }
  327. })
  328. if (!ok) {
  329. return uni.showToast({
  330. title: msg,
  331. icon: "none"
  332. })
  333. }
  334. uni.showModal({
  335. title: "确认保存吗?",
  336. success: async res => {
  337. if (res.confirm) {
  338. this.disabledSubmit = true
  339. await this._saveIncommissionwarehouse()
  340. this.disabledSubmit = false
  341. uni.showToast({
  342. title: "保存成功"
  343. })
  344. uni.reLaunch({
  345. url:"/pages/index/index"
  346. })
  347. }
  348. }
  349. })
  350. },
  351. // 格式化取消提交的数据
  352. _formatCancelChoosedList () {
  353. this.showChoosedList=false
  354. },
  355. // 取消提交
  356. onCancelChoosed () {
  357. this._formatCancelChoosedList()
  358. },
  359. // 保存接口
  360. async _saveIncommissionwarehouse () {
  361. let CKH=null,KWH=null,items=[];
  362. if (this.detail.LXSM===TEXT_CPWW) {
  363. CKH=this.toCkList[this.toCkIndex].CKH
  364. KWH=this.toKwList[this.toKwIndex].KWH
  365. }
  366. this.choosedList.forEach(item=>{
  367. items.push({ "DDHH":item.HH,"SL":item.amount})
  368. })
  369. const reqdata={
  370. "WWDDH":this.DDH, //委外订单号
  371. "CKH":CKH, // 仓库号
  372. "KWH":KWH, //库位号
  373. "items":items
  374. }
  375. const resdata=await saveIncommissionwarehouse(reqdata)
  376. setTimeout(()=>{
  377. this.disabledSubmit = false
  378. },1000)
  379. return resdata
  380. }
  381. }
  382. }
  383. </script>
  384. <style lang="scss" scoped>
  385. @import "~@/common/styles/outsource.scss"
  386. </style>