addStock.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="新增物料入库单" @clickLeft="back">
  4. <!--右菜单-->
  5. <template slot="float">
  6. <view class="nav-icon-caozuo rightNav" @click="getsure"><u-button type="success" size="small" class="u-reset-button" text="确定"></u-button></view>
  7. </template>
  8. </uni-nav-bar>
  9. <u-cell-group>
  10. <picker @change="getTypeList" :value="pickerIndex" :range="enterType" range-key="name">
  11. <u-cell title="入库类型" :value="form.enterTypeName?form.enterTypeName:'无'" :isLink="true"></u-cell>
  12. </picker>
  13. <picker @change="getWarehouse" :value="pickerIndex" :range="warehouse" range-key="name">
  14. <u-cell title="仓库" :value="form.warehouse.name?form.warehouse.name:'无'" :isLink="true"></u-cell>
  15. </picker>
  16. <picker @change="getExecutor" :value="pickerIndex" :range="executor" range-key="name">
  17. <u-cell title="入库登记人" :value="form.executor.name?form.executor.name:'无'" :isLink="true"></u-cell>
  18. </picker>
  19. <picker @change="getSupplier" :value="pickerIndex" :range="supplier" range-key="name">
  20. <u-cell title="供应商" :value="form.supplier.name?form.supplier.name:'无'" :isLink="true"></u-cell>
  21. </picker>
  22. <u-cell title="送货人" :value="form.sendName?form.sendName:'无'" :isLink="true" @click="getSendName()"></u-cell>
  23. <u-cell title="送货人联系方式" :value="form.sendPhone?form.sendPhone:'无'" :isLink="true" @click="getSendPhone()"></u-cell>
  24. <u-cell title="送货时间" :isLink="true">
  25. <view slot="value" class="u-slot-value">
  26. <uni-datetime-picker v-model="form.sendTime">{{form.sendTime}}</uni-datetime-picker>
  27. </view>
  28. </u-cell>
  29. </u-cell-group>
  30. <u-collapse class="cLine" :value="['detail']">
  31. <u-collapse-item title="附件" name="">
  32. <view class="picList">
  33. <upload-File module="物料入库单" @getUpFlie="getUpFlie"></upload-File>
  34. </view>
  35. </u-collapse-item>
  36. <u-collapse-item title="描述" name="">
  37. <textarea class="textBox" placeholder-style="color:#ddd" placeholder="请输入备注信息" v-model="form.remark" />
  38. </u-collapse-item>
  39. </u-collapse>
  40. <uni-section title="明细" type="line">
  41. <view class="listBox" v-for="(item, index) in form.numDetails" :key="index" >
  42. <view class="listTit">
  43. <view style="display:inline-block;"><!--<u-tag :text="item.manageType.name" size="mini" shape="circle" :type="item.manageType.id==2?'primary':'success'"></u-tag>--></view>
  44. <view class="name">{{item.name}}</view>
  45. <view class="weight">{{item.totalNum}}{{item.unit}}</view>
  46. <view class="delete" @click="getDelete(index)"><uni-icons custom-prefix="iconfont" type="icon-shanchu" size="24" color="#fa3534"></uni-icons></view>
  47. </view>
  48. <view class="listCont">
  49. <view class="item"><text>编码:</text>{{item.code}}</view>
  50. <view class="item"><text>批次号:</text>{{item.batchNo}}</view>
  51. <view class="item"><text>有效期:</text>{{item.expireDate}}</view>
  52. <view class="item"><text>包装单位:</text>{{item.unit}}</view>
  53. <view class="item"><text>应入数量:</text>{{item.num}}</view>
  54. </view>
  55. </view>
  56. </uni-section>
  57. <view class="footBox">
  58. <view class="add" @click="getAddDetails"><uni-icons custom-prefix="iconfont" type="icon-shixiangxinzeng" size="20" color="#fff"></uni-icons> 添加明细</view>
  59. <view class="reg" @click="getAddDetails"><uni-icons type="scan" color="#fff" size="20"></uni-icons> 扫码添加</view>
  60. </view>
  61. <getinput :show="showInput" @openInput="getInput" @getInputInfo="getInputInfo"></getinput>
  62. <addDetails
  63. :show="showChoose"
  64. title="请选择明细"
  65. :tabList="tabList"
  66. :materTree = "materTree"
  67. @openChoose="getChoose"
  68. @getChooseInfo="getChooseInfo">
  69. </addDetails>
  70. </view>
  71. </template>
  72. <script>
  73. import {getDate,stopScroll,startScroll} from '@/utils/utils.js';
  74. import { post,postJ,get } from "@/utils/api.js";
  75. import getinput from '@/components/Getinput';
  76. import addDetails from '@/components/addDetails';
  77. import uploadFile from '@/components/uploadFile';
  78. export default {
  79. components: {
  80. getinput,
  81. uploadFile,
  82. addDetails
  83. },
  84. data() {
  85. return {
  86. form: {
  87. enterType:'', //入库类型
  88. enterTypeName:'', //入库类型名称
  89. warehouse:{}, //仓库
  90. executor:{}, //登记人
  91. supplier:{}, //供应商
  92. sendName:'', //送货人
  93. sendPhone:'', //联系方式
  94. sendTime:'', //送货时间
  95. attaments: [], //附件
  96. remark:'', //备注
  97. numDetails:[], //已选列表
  98. },
  99. enterType: [], //入库类型
  100. warehouse: [], //仓库
  101. executor: [], //登记人
  102. supplier: [], //供应商
  103. pickerIndex:0,
  104. showInput: false, //显示底部输入框
  105. temp:'', //临时值
  106. showChoose: false, //添加明细开关
  107. tabList:[
  108. {
  109. value:0,
  110. label:"物料树"
  111. },
  112. {
  113. value:1,
  114. label:"物料台账列表"
  115. },
  116. {
  117. value:2,
  118. label:"已选物料"
  119. }
  120. ],
  121. materTree:[], //产品树
  122. }
  123. },
  124. onShow(){
  125. //获取选项数据
  126. this.getData();
  127. },
  128. mounted(){
  129. this.form.sendTime = getDate();
  130. },
  131. methods: {
  132. //获取选项数据
  133. async getData(){
  134. //入库类型
  135. let typeInfo = await get(this.apiWebUrl + "/data/dict/source", {code: 'wh,enter_material_type'});
  136. this.enterType = typeInfo.data.enter_material_type;
  137. //仓库
  138. this.warehouse = typeInfo.data.wh;
  139. //供应商
  140. let supplier = await get(this.apiWebUrl + "/data/dict/source", {code: 'company_info',rela: 5,});
  141. this.supplier = supplier.data.company_info;
  142. //入库登记人
  143. let executor = await postJ(this.apiWebUrl + "/main/user/users",{});
  144. this.executor = executor.data;
  145. //获取产品树
  146. let materTree = await get(this.apiWebUrl + "/main/material/type/tree",{model:2});
  147. setTimeout(()=>{
  148. let newMaterTree = materTree.data;
  149. newMaterTree.forEach(function(res, key) {
  150. newMaterTree[key].childOpen = false;
  151. })
  152. this.materTree = newMaterTree;
  153. },600)
  154. },
  155. //获取入库类型
  156. getTypeList(e){
  157. this.form.enterType = this.enterType[e.detail.value].id;
  158. this.form.enterTypeName = this.enterType[e.detail.value].name;
  159. },
  160. //获取仓库信息
  161. getWarehouse(e){
  162. this.form.warehouse = this.warehouse[e.detail.value];
  163. },
  164. //获取供应商信息
  165. getSupplier(e){
  166. this.form.supplier = this.supplier[e.detail.value];
  167. },
  168. //入库登记人
  169. getExecutor(e){
  170. this.form.executor = this.executor[e.detail.value];
  171. },
  172. //填写送货人信息
  173. getSendName(){
  174. this.showInput = !this.showInput;
  175. this.team = "sendName";
  176. },
  177. //填写送货人电话
  178. getSendPhone(){
  179. this.showInput = !this.showInput;
  180. this.team = "sendPhone";
  181. },
  182. //输入框开关
  183. getInput(){
  184. this.showInput = !this.showInput;
  185. },
  186. //接收输入框数据
  187. getInputInfo(res){
  188. if(this.team == 'sendName'){
  189. this.form.sendName = res;
  190. }else if(this.team == 'sendPhone'){
  191. this.form.sendPhone = res;
  192. }
  193. },
  194. //上传附件
  195. getUpFlie(res){
  196. this.form.attaments = res;
  197. },
  198. //添加明细开关
  199. getChoose(){
  200. this.showChoose = !this.showChoose;
  201. if(!this.showChoose){
  202. startScroll(); //还原滚动条
  203. }
  204. },
  205. //添加入库明细
  206. getAddDetails(){
  207. this.showChoose = true;
  208. stopScroll(); //停止滚动条
  209. },
  210. //接收添加入库明细
  211. getChooseInfo(res){
  212. this.form.numDetails = res;
  213. //console.log(this.form);
  214. },
  215. //删除
  216. getDelete(index){
  217. this.form.numDetails.splice(index,1);
  218. },
  219. //确定
  220. getsure(){
  221. console.log(this.form);
  222. if(this.form.numDetails.length < 1){
  223. uni.showToast({
  224. icon:"none",
  225. title: '请选择添加明细'
  226. });
  227. return;
  228. }
  229. let data = JSON.stringify(this.form);
  230. postJ(this.apiWebUrl + "/wms/enter/material/save",data).then((res)=>{
  231. console.log(res);
  232. });
  233. },
  234. }
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. .mainBox{
  239. padding-bottom: 120rpx;
  240. }
  241. .picList{
  242. display: flex;
  243. align-items: center;
  244. justify-items: flex-start;
  245. flex-wrap: wrap;
  246. }
  247. /deep/.picList .u-image{
  248. margin-right:10rpx;
  249. margin-bottom: 10rpx;
  250. }
  251. /deep/.cLine .u-line:nth-child(1){
  252. border-bottom: none !important;
  253. }
  254. .footBox{
  255. position: fixed;
  256. left:0px;
  257. bottom: 0px;
  258. height: 100rpx;
  259. width: 100%;
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. view{
  264. width:50%;
  265. height: 100%;
  266. text-align: center;
  267. color: #fff;
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. }
  272. .reg{
  273. background: $u-success-dark;
  274. }
  275. .add{
  276. background: $uni-color-primary;
  277. }
  278. .uni-icons{margin-right: 8rpx !important;}
  279. }
  280. .listBox{
  281. padding: 20rpx;
  282. border-bottom:1px #f2f2f2 solid;
  283. .listTit{
  284. display: flex;
  285. align-items: center;
  286. .name{
  287. width: 50%;
  288. margin-left: 10px;
  289. overflow: hidden;
  290. white-space:nowrap;
  291. -o-text-overflow:ellipsis;
  292. text-overflow:ellipsis;
  293. overflow: hidden;
  294. font-size: $uni-font-size-base;
  295. }
  296. .weight {
  297. font-size: $uni-font-size-base;
  298. margin-left: auto;
  299. margin-right: 60rpx;
  300. position: relative;
  301. }
  302. .weight::after{
  303. position: absolute;
  304. right:-30rpx;
  305. top:50%;
  306. content: '';
  307. background: #eee;
  308. width: 1px;
  309. height: 28rpx;
  310. margin-top: -14rpx;
  311. }
  312. }
  313. .listCont{
  314. display: flex;
  315. align-items: center;
  316. flex-wrap: wrap;
  317. margin-top: 15px;
  318. .item{
  319. width:50%;
  320. font-size: $uni-font-size-sm;
  321. line-height: 48rpx;
  322. overflow: hidden;
  323. white-space: nowrap;
  324. text-overflow: ellipsis;
  325. -o-text-overflow:ellipsis;
  326. color: #000;
  327. }
  328. .item text{color: #666;}
  329. }
  330. }
  331. .listBox:last-child{
  332. border:none !important;
  333. }
  334. .textBox{
  335. border: 1px #f2f2f2 solid;
  336. height: 160px;
  337. display: block;
  338. width: auto !important;
  339. }
  340. .saveBtn{
  341. width:50%;
  342. margin:40rpx auto;
  343. }
  344. </style>