spare-store-transfer.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="mx3" style="padding-bottom: 100rpx">
  3. <u-toast ref="uToast" />
  4. <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
  5. <view
  6. class="p3 bg-color-white"
  7. style="margin-top: -50rpx; border-radius: 20rpx"
  8. >
  9. <u-form :model="form" ref="uForm" >
  10. <view class="main-color-text f-size-32 f-weight-6 mt-2">调拨信息</view>
  11. <u-form-item label="调出仓库" :label-width="150">
  12. <u-input v-model="form.storeName" disabled />
  13. </u-form-item>
  14. <u-form-item label="调入仓库" required prop="running" :label-width="150">
  15. <u-input
  16. v-model="form.inStoreName"
  17. disabled
  18. @click="handleSelect"
  19. placeholder="请选择仓库"
  20. type="select"
  21. />
  22. </u-form-item>
  23. <u-form-item label="备件名称" :label-width="150">
  24. <u-input v-model="form.spareName" disabled />
  25. </u-form-item>
  26. <u-form-item label="备件编号" :label-width="150">
  27. <u-input v-model="form.spareNo" disabled />
  28. </u-form-item>
  29. <u-form-item label="库存价格" prop="price" required :label-width="150">
  30. <u-input v-model="form.price"/>
  31. </u-form-item>
  32. <u-form-item label="库存数量" prop="num" required :label-width="150">
  33. <u-input v-model="form.storeNum" :cursor-spacing="cursorSpacing"/>
  34. </u-form-item>
  35. <u-form-item label="调拨数量" prop="storeNum" required :label-width="150">
  36. <u-input v-model="form.num" :cursor-spacing="cursorSpacing"/>
  37. </u-form-item>
  38. </u-form>
  39. <!-- <button class="main-color-bg text-color-white" @tap='handleSubmit'>提交</button> -->
  40. <view class="p-fixed d-flex j-around a-center footer">
  41. <view
  42. class="main-color-bg text-color-white common"
  43. @tap="handleSubmit"
  44. >提交</view
  45. >
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. form: {
  55. price: '',
  56. spareName: '',
  57. spareId: '',
  58. spareNo: '',
  59. storeId: '',
  60. storeName: '',
  61. inStoreName: '',
  62. inStoreId: '',
  63. num: ''
  64. },
  65. data: [],
  66. badState: false,
  67. badList: [],
  68. runningState: false, // 设备选择
  69. runningList: [],
  70. haltState: false, // 是否停机
  71. haltList: [],
  72. repairState: false, // 报修来源
  73. repairList: [],
  74. levelState: false,
  75. levelList: [],
  76. imagesList: [],
  77. action: this.$BaseTool.UserUtil.getUploadUrlIgnores(),
  78. // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
  79. /*header: {
  80. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  81. },*/
  82. fileList: [],
  83. sourceMap: {},
  84. levelMap: {},
  85. statusMap: {},
  86. needStopMap: {},
  87. haltDefaultValue: [0],
  88. rules: {
  89. num: [
  90. {
  91. required: true,
  92. message: '请填写出库数量',
  93. trigger: ['blur', 'change']
  94. }
  95. ],
  96. price: [
  97. {
  98. required: true,
  99. message: '请填写库存价格',
  100. trigger: ['blur', 'change']
  101. }
  102. ]
  103. },
  104. // #ifdef MP-WEIXIN
  105. cursorSpacing: 50,
  106. // #endif
  107. // #ifndef MP-WEIXIN
  108. cursorSpacing: 0,
  109. // #endif
  110. backId: '',
  111. backName: '',
  112. aShow: false,
  113. address: '',
  114. sbId: null,
  115. aList: [
  116. ]
  117. };
  118. },
  119. onShow() {
  120. const pages = getCurrentPages();
  121. const currPage = pages[pages.length - 1];
  122. this.backId = currPage.backId;
  123. this.backName = currPage.backName;
  124. this.form.inStoreName = this.backName;
  125. this.form.inStoreId = this.backId;
  126. console.log('this.form.inStoreName:' + this.form.inStoreName)
  127. },
  128. onLoad(options) {
  129. this.form.spareId = options.spareId;
  130. this.form.spareName = options.spareName;
  131. this.form.spareNo = options.spareNo;
  132. this.form.storeNum = options.storeNum;
  133. this.form.storeId = options.storeId;
  134. this.form.storeName = options.storeName;
  135. this.form.price = options.price;
  136. this.sourceMap = this.$DictCache.getLabelByValueMapByType(
  137. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
  138. );
  139. for (const key in this.sourceMap) {
  140. this.repairList.push({
  141. label: this.sourceMap[key],
  142. value: key
  143. });
  144. }
  145. this.form.repair = this.repairList[0].label;
  146. this.form.source = this.repairList[0].value;
  147. this.levelMap = this.$DictCache.getLabelByValueMapByType(
  148. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
  149. );
  150. for (const key in this.levelMap) {
  151. this.levelList.push({
  152. label: this.levelMap[key],
  153. value: key
  154. });
  155. }
  156. this.form.level = this.levelList[0].label;
  157. this.form.levelValue = this.levelList[0].value;
  158. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  159. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  160. );
  161. this.needStopMap = this.$DictCache.getLabelByValueMapByType(
  162. this.$DictCache.TYPE.YES_NO
  163. );
  164. for (const key in this.needStopMap) {
  165. this.haltList.push({
  166. label: this.needStopMap[key],
  167. value: key
  168. });
  169. }
  170. this.form.halt = this.haltList[this.haltDefaultValue].label;
  171. this.form.needStop = this.haltList[this.haltDefaultValue].value;
  172. this.getType()
  173. // 获取设备数据
  174. // this.initSb();
  175. },
  176. onReady() {
  177. this.$refs.uForm.setRules(this.rules);
  178. },
  179. methods: {
  180. //
  181. confirm(e) {
  182. console.log(e);
  183. this.address = ''
  184. for (let i = 0; i < e.length; i++) {
  185. this.address += e[i].label
  186. }
  187. },
  188. badSubmit(data) {
  189. this.form.badType = data[0].label;
  190. this.form.repairErrorTypeId = data[0].value;
  191. },
  192. getType() {
  193. /* this.$Http
  194. .fetchErrorTypeTree({
  195. id: this.detailId
  196. })
  197. .then((res) => {
  198. console.log(res.data);
  199. const temp = []
  200. res.data.forEach(item => {
  201. temp.push({
  202. label: item.title,
  203. value: item.id
  204. })
  205. })
  206. this.badList = temp
  207. console.log(this.badList);
  208. }) */
  209. },
  210. handleSelect() {
  211. uni.navigateTo({
  212. url: '/pages/search/search-store'
  213. })
  214. },
  215. // 选择仓库
  216. runningSubmit(data) {
  217. console.log(data);
  218. this.form.storeId = data.value;
  219. this.$Http
  220. .fetchStore({
  221. id: data.value
  222. })
  223. .then((res) => {
  224. this.form.storeName = res.data.name;
  225. this.form.running = res.data.name;
  226. });
  227. this.form.running = data.label;
  228. },
  229. handleSubmit() {
  230. if(this.form.storeNum<=0){
  231. uni.showToast({ icon: 'none', title: '库存数量为0,无法调拨!', duration: 2000 });
  232. return
  233. }
  234. if(this.form.num<=0){
  235. uni.showToast({ icon: 'none', title: '出库数量必须大于0!', duration: 2000 });
  236. return
  237. }
  238. if((this.form.storeNum - this.form.num) <= 0){
  239. uni.showToast({ icon: 'none', title: '调拨数量不得大于库存数量!', duration: 2000 });
  240. return
  241. }
  242. if(this.form.storeId == this.form.inStoreId){
  243. uni.showToast({ icon: 'none', title: '请选择不同的仓库!', duration: 2000 });
  244. return
  245. }
  246. const params = {
  247. storeId: this.form.storeId,
  248. inStoreId: this.form.inStoreId,
  249. detailList:[{
  250. price: this.form.price,
  251. spareId: this.form.spareId,
  252. storeId: this.form.storeId,
  253. num: this.form.num
  254. }]
  255. };
  256. // this.form.photo = a.join(',');
  257. var that = this;
  258. this.$refs.uForm.validate((valid) => {
  259. if (valid) {
  260. this.$Http.addTransferStoreForm(params).then((res) => {
  261. uni.showToast({ icon: 'none', title: '已提交!', duration: 2000 });
  262. setTimeout(function () {
  263. uni.navigateTo({
  264. url: '/pages/spare/spare-store?detailId=' + that.form.spareId
  265. });
  266. }, 2000)
  267. });
  268. }
  269. });
  270. }
  271. }
  272. };
  273. </script>
  274. <style lang="less">
  275. .footer {
  276. bottom: 0;
  277. left: 0;
  278. right: 0;
  279. background-color: #fff;
  280. z-index: 10000;
  281. border-top: 1rpx solid #f4f4f4;
  282. height: 100rpx;
  283. .common {
  284. padding: 15rpx 200rpx;
  285. border-radius: 30rpx;
  286. background-color: #0082ff;
  287. color: #fff;
  288. }
  289. }
  290. </style>