otherStorage.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="storage">
  3. <div class="btn-click">
  4. <span class="base-color" @click="saveClick()">保存</span>
  5. <span class="clear" @click="saveClick('clear')">取消</span>
  6. </div>
  7. <div class="storage-info">
  8. <div class="linetext">{{switchType === 'INBOUND' ? '入库单' : '出库单'}}:<span>系统自动生成</span></div>
  9. <div class="linetext">{{switchType === 'INBOUND' ? '卖家名称' : '买家名称'}}:
  10. <span><input type="text" v-model="enName" :placeholder="switchType === 'INBOUND' ? '请输入卖家名称' : '请输入买家名称'"></span>
  11. </div>
  12. <div class="linetext">录入人: <span v-text="user.logged">21324</span></div>
  13. <div class="linetext">录入时间: <span v-text="baseUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')">21324</span></div>
  14. </div>
  15. <ul class="list-unstyled">
  16. <li class="info-list clearfix" v-for="(item, index) in allObj">
  17. <span class="super"><em v-text="index + 1">1</em></span>
  18. <div class="linetext width50 fl">型号:
  19. <span>
  20. <input type="text" style="width:2rem;" v-model="item.cmpCode" @input="onCodeChange(index)" placeholder="">
  21. </span>
  22. </div>
  23. <div class="linetext width50 fl">品牌: <span v-text="item.brand">21324</span></div>
  24. <div class="linetext width50 fl">物料名称: <span v-text="item.pcmpcode">21324</span></div>
  25. <div class="linetext width50 fl">规格: <span v-text="item.spec">21324</span></div>
  26. <div class="linetext width50 fl"><em>*</em>{{switchType === 'INBOUND' ? '入库数' : '出库数'}}(PCS): <span><input type="text" style="width:1rem;" v-model.number="item.qty"></span></div>
  27. <div class="linetext width50 fl">单价(¥):<span><input type="text" style="width:2rem;" v-model.number="item.price"></span></div>
  28. <div class="content-line" v-show="item.showSimilarCodeList && item.cmpCode">
  29. <ul class="similar">
  30. <li v-for="sCode in similarCode" @click.stop="setCode(sCode, index)">
  31. <span v-text="sCode.cmpCode"></span>
  32. <span v-text="sCode.brand"></span>
  33. </li>
  34. </ul>
  35. </div>
  36. <div class="look-btn">
  37. <span @click="addClick()" v-if="index === allObj.length - 1">新增</span>
  38. <span @click="addClick(index)" v-if="index !== 0">删除</span>
  39. </div>
  40. </li>
  41. </ul>
  42. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  43. </div>
  44. </template>
  45. <script>
  46. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  47. export default {
  48. props: {
  49. switchType: {
  50. type: String,
  51. default: 'INBOUND'
  52. }
  53. },
  54. data () {
  55. return {
  56. remindText: '',
  57. timeoutCount:0,
  58. enName: '',
  59. allObj:[],
  60. storageObj: {
  61. cmpCode: '',
  62. brand: '',
  63. pcmpcode: '',
  64. spec: '',
  65. qty: '',
  66. price: '',
  67. showSimilarCodeList: false,
  68. },
  69. similarCode:[]
  70. }
  71. },
  72. components: {
  73. RemindBox
  74. },
  75. mounted () {
  76. let _this = this
  77. this.allObj.push(this.storageObj)
  78. document.body.onclick = function() {
  79. _this.showSimilarCodeList = false
  80. }
  81. },
  82. methods: {
  83. onRemind: function (str) {
  84. this.remindText = str
  85. this.timeoutCount++
  86. },
  87. setFilterType (type) {
  88. let bound = ''
  89. if(type === 'OTHER_INBOUND') {
  90. bound = '其他入库'
  91. } else if(type === 'OTHER_OUTBOUND'){
  92. bound = '其他出库'
  93. } else if (type === 'PURCHASE_INBOUND') {
  94. bound = '采购入库'
  95. } else if(type === 'SELL_OUTBOUND') {
  96. bound = '销售出库'
  97. } else {
  98. bound = '全部类型'
  99. }
  100. return bound
  101. },
  102. initData () {
  103. this.enName = ''
  104. this.allObj = []
  105. this.allObj.push(this.storageList)
  106. },
  107. onCodeChange (type) {
  108. this.allObj[type].showSimilarCodeList = true
  109. this.allObj[type].cmpCode = this.allObj[type].cmpCode.trim()
  110. this.getSimilarCode(type)
  111. },
  112. getSimilarCode: function (type) {
  113. if (this.allObj[type].cmpCode) {
  114. this.$http.get('/trade/products/code/keyword', {params: {keyword: this.allObj[type].cmpCode}})
  115. .then(response => {
  116. if(response.data){
  117. this.similarCode = response.data || []
  118. } else {
  119. this.onRemind('没有找到产品信息')
  120. }
  121. this.allObj[type].showSimilarCodeList = response.data.length > 0
  122. }).catch((err) => {
  123. this.allObj[type].showSimilarCodeList = false
  124. this.similarCode = []
  125. this.onRemind('没有找到产品信息')
  126. })
  127. } else {
  128. this.allObj[type].showSimilarCodeList = false
  129. }
  130. },
  131. setCode (data, type) {
  132. this.allObj[type].cmpCode = data.cmpCode
  133. this.allObj[type].brand = data.pbranden
  134. this.allObj[type].pcmpcode = data.kind
  135. this.allObj[type].spec = data.spec
  136. this.allObj[type].productId = data.id
  137. this.allObj[type].showSimilarCodeList = false
  138. },
  139. addClick (type) {
  140. if(type) {
  141. this.allObj.splice(type, 1)
  142. } else {
  143. let _item = {
  144. cmpCode: '',
  145. brand: '',
  146. pcmpcode: '',
  147. spec: '',
  148. qty: '',
  149. price: '',
  150. showSimilarCodeList: false,
  151. }
  152. this.allObj.push(_item)
  153. }
  154. },
  155. saveClick (type) {
  156. if(type === 'clear') {
  157. console.log('clear')
  158. this.initData()
  159. }else {
  160. if(!this.enName) {
  161. this.onRemind('请输入' + this.switchType === 'INBOUND' ? '请输入卖家名称' : '请输入买家名称')
  162. } else {
  163. let arr = []
  164. this.allObj.forEach(val => {
  165. if(!val.price && !val.qty && !val.productId) {
  166. this.onRemind('请将数据补充完整')
  167. return
  168. }
  169. arr.push({price: val.price, productId: val.productId, qty:val.qty})
  170. })
  171. this.$http.post(`/CommodityInOutbound/${this.switchType === 'INBOUND'? 'inBound': 'outBound'}/other?enName=${this.enName}`, arr)
  172. .then(response => {
  173. if(response.data.code === 1){
  174. this.onRemind('保存信息成功')
  175. }
  176. })
  177. }
  178. }
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. $base-color: #3f84f6;
  185. $title-color: #ffa200;
  186. $red-color: #ff0000;
  187. .storage{
  188. position: relative;
  189. margin-bottom:.3rem;
  190. .btn-click{
  191. padding: 0.24rem 0.24rem;
  192. position: fixed;
  193. bottom: 1rem;
  194. left: 0;
  195. right: 0;
  196. text-align: center;
  197. span{
  198. display:inline-block;
  199. width:30%;
  200. height: .6rem;
  201. line-height: .6rem;
  202. margin: 0 .1rem;
  203. border-radius:.05rem;
  204. &.clear{
  205. color:#fafbfc;
  206. background: #b5b5b5;
  207. }
  208. &.base-color{
  209. color:#fff;
  210. background: $base-color;
  211. }
  212. }
  213. }
  214. .storage-info{
  215. padding: 0.24rem 0.24rem;
  216. background: #fff;
  217. margin-bottom:.2rem;
  218. }
  219. .content-line{
  220. position: absolute;
  221. border: 1px solid #7e7e7e;
  222. border-radius: .05rem;
  223. left: .3rem;
  224. top: 32%;
  225. background: #fff;
  226. width: 6.5rem;
  227. max-height: 2.5rem;
  228. overflow-y: auto;
  229. z-index: 12;
  230. .similar {
  231. li {
  232. height: .5rem;
  233. line-height: .5rem;
  234. font-size: .26rem;
  235. color: #999;
  236. padding-left: .19rem;
  237. &:focus, &:active, &:hover {
  238. background: #999;
  239. color: #fff;
  240. }
  241. span{
  242. display: inline-block;
  243. width: 50%;
  244. overflow: hidden;
  245. text-overflow: ellipsis;
  246. white-space: nowrap;
  247. }
  248. }
  249. }
  250. }
  251. .look-btn{
  252. position: absolute;
  253. bottom: 0;
  254. left: 0;
  255. width: 100%;
  256. border-top: 1px solid #d3d3d3;
  257. text-align: center;
  258. span{
  259. display:inline-block;
  260. width:50%;
  261. text-align: center;
  262. line-height: .8rem;
  263. }
  264. }
  265. .linetext{
  266. color:#666;
  267. line-height: .6rem;
  268. overflow: hidden;
  269. -o-text-overflow: ellipsis;
  270. text-overflow: ellipsis;
  271. white-space: nowrap;
  272. input{
  273. height: .5rem;
  274. font-size: .24rem;
  275. border-radius: .04rem;
  276. border: 1px solid #d2d2d2;
  277. padding: 0 .1rem;
  278. }
  279. em{
  280. color:$red-color;
  281. }
  282. span{
  283. color:#333;
  284. &.base-color{
  285. color:$base-color;
  286. }
  287. }
  288. }
  289. > ul{
  290. margin-bottom:1rem;
  291. }
  292. .info-list{
  293. position:relative;
  294. padding: 0.3rem 0.24rem 1rem;
  295. background: #fff;
  296. margin-bottom:.2rem;
  297. .width50{
  298. display:inline-block;
  299. width: 48%;
  300. margin-left: .1rem;
  301. }
  302. >span{
  303. display:inline-block;
  304. position:absolute;
  305. left:0;
  306. top:0;
  307. padding: 0 .1rem;
  308. background: $title-color;
  309. border-radius: 0 .5rem .5rem 0;
  310. line-height: .3rem;
  311. height:.3rem;
  312. color:#fff;
  313. font-size: .24rem;
  314. }
  315. }
  316. }
  317. </style>