spare-store-out.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. <!-- <u-form-item label="选择设备" required prop="running" :label-width="150">
  11. <u-input
  12. v-model="form.running"
  13. disabled
  14. @click="handleSelect"
  15. placeholder="请选择设备"
  16. type="select"
  17. />
  18. <u-select
  19. v-model="haltState"
  20. :list="runningList"
  21. @confirm="runningSubmit"
  22. ></u-select> -->
  23. </u-form-item>
  24. <common-popup :list="runningList" @select="runningSubmit" ref="popup" />
  25. <view class="main-color-text f-size-32 f-weight-6 mt-2">备件信息</view>
  26. <u-form-item label="备件名称" :label-width="150">
  27. <u-input v-model="form.spareName" disabled />
  28. </u-form-item>
  29. <u-form-item label="备件编号" :label-width="150">
  30. <u-input v-model="form.spareNo" disabled />
  31. </u-form-item>
  32. <view class="main-color-text f-size-32 f-weight-6 mt-2">出库仓库信息</view>
  33. <u-form-item label="仓库名称" :label-width="150">
  34. <u-input v-model="form.storeName" disabled />
  35. </u-form-item>
  36. <u-form-item label="库存价格" :label-width="150">
  37. <u-input v-model="form.price" disabled/>
  38. </u-form-item>
  39. <u-form-item label="库存数量" :label-width="150">
  40. <u-input v-model="form.storeNum" disabled/>
  41. </u-form-item>
  42. <u-form-item label="出库数量" prop="num" required :label-width="150">
  43. <u-input v-model="form.num" :cursor-spacing="cursorSpacing" />
  44. </u-form-item>
  45. <!--<u-form-item label="上传图片" :label-width="150">
  46. <u-upload
  47. width="180"
  48. height="180"
  49. max-count="6"
  50. :action="action"
  51. :file-list="fileList"
  52. @on-success="uploadSuccess"
  53. @on-remove="uploadRemove"></u-upload>
  54. </u-form-item>-->
  55. </u-form>
  56. <!-- <button class="main-color-bg text-color-white" @tap='handleSubmit'>提交</button> -->
  57. <view class="p-fixed d-flex j-around a-center footer">
  58. <view
  59. class="main-color-bg text-color-white common"
  60. @tap="handleSubmit"
  61. >提交</view
  62. >
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. form: {
  72. price: '',
  73. spareName: '',
  74. spareId: '',
  75. spareNo: '',
  76. storeId: '',
  77. storeName: '',
  78. storeNum: ''
  79. },
  80. data: [],
  81. badState: false,
  82. badList: [],
  83. runningState: false, // 设备选择
  84. runningList: [],
  85. haltState: false, // 是否停机
  86. haltList: [],
  87. repairState: false, // 报修来源
  88. repairList: [],
  89. levelState: false,
  90. levelList: [],
  91. imagesList: [],
  92. action: this.$BaseTool.UserUtil.getUploadUrlIgnores(),
  93. // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
  94. /*header: {
  95. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  96. },*/
  97. fileList: [],
  98. sourceMap: {},
  99. levelMap: {},
  100. statusMap: {},
  101. needStopMap: {},
  102. haltDefaultValue: [0],
  103. rules: {
  104. num: [
  105. {
  106. required: true,
  107. message: '请填写出库数量',
  108. trigger: ['blur', 'change']
  109. }
  110. ]
  111. },
  112. // #ifdef MP-WEIXIN
  113. cursorSpacing: 50,
  114. // #endif
  115. // #ifndef MP-WEIXIN
  116. cursorSpacing: 0,
  117. // #endif
  118. sbBackId: '',
  119. aShow: false,
  120. address: '',
  121. sbId: null,
  122. aList: [
  123. ]
  124. };
  125. },
  126. onShow() {
  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.storeId = options.storeId;
  133. this.form.storeNum = options.storeNum;
  134. this.form.price = options.price;
  135. this.form.storeName = options.storeName;
  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'
  213. })
  214. },
  215. handleSubmit() {
  216. if(this.form.storeNum<=0){
  217. uni.showToast({ icon: 'none', title: '库存数量为0,无法出库!', duration: 2000 });
  218. return
  219. }
  220. if(this.form.num<=0){
  221. uni.showToast({ icon: 'none', title: '出库数量必须大于0!', duration: 2000 });
  222. return
  223. }
  224. if(this.form.storeNum< this.form.num){
  225. uni.showToast({ icon: 'none', title: '出库数量不得大于库存数量!', duration: 2000 });
  226. return
  227. }
  228. const params = {
  229. storeId: this.form.storeId,
  230. detailList:[{
  231. price: this.form.price,
  232. spareId: this.form.spareId,
  233. storeId: this.form.storeId,
  234. num: this.form.num
  235. }]
  236. };
  237. // this.form.photo = a.join(',');
  238. var that = this;
  239. this.$refs.uForm.validate((valid) => {
  240. if (valid) {
  241. this.$Http.addOutStoreForm(params).then((res) => {
  242. uni.showToast({ icon: 'none', title: '出库单已提交!', duration: 2000 });
  243. setTimeout(function () {
  244. uni.navigateTo({
  245. url: '/pages/spare/spare-store?detailId=' + that.form.spareId
  246. });
  247. }, 2000)
  248. });
  249. }
  250. });
  251. }
  252. }
  253. };
  254. </script>
  255. <style lang="less">
  256. .footer {
  257. bottom: 0;
  258. left: 0;
  259. right: 0;
  260. background-color: #fff;
  261. z-index: 10000;
  262. border-top: 1rpx solid #f4f4f4;
  263. height: 100rpx;
  264. .common {
  265. padding: 15rpx 200rpx;
  266. border-radius: 30rpx;
  267. background-color: #0082ff;
  268. color: #fff;
  269. }
  270. }
  271. </style>