spare-store-add.vue 11 KB

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