running-batch-edit.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="mx3">
  3. <view class="main-color-bg main-bg-future"></view>
  4. <view class="p3 bg-color-white form-view">
  5. <u-form :model="form" ref="uForm" >
  6. <u-form-item
  7. label="作业名称"
  8. prop="projectQuantityId"
  9. :label-width="220">
  10. <my-select
  11. :list="projectQuantityList"
  12. :value-name="'id'"
  13. :label-name="'name'"
  14. v-model="form.projectQuantityId"
  15. @selected="changeProjectQuantity"
  16. placeholder="请选择"
  17. />
  18. </u-form-item>
  19. <u-form-item
  20. label="作业位置"
  21. :label-width="220">
  22. <view class="d-flex">
  23. <u-input
  24. style="width: 100rpx;"
  25. v-model="form.projectQuantityStart"
  26. type="number"
  27. @blur="numBlur($event, 'projectQuantityStart')"
  28. placeholder="起始值" />
  29. <text class="px3">至</text>
  30. <u-input
  31. style="width: 100rpx;"
  32. v-model="form.projectQuantityEnd"
  33. type="number"
  34. @blur="numBlur($event, 'projectQuantityEnd')"
  35. placeholder="结束值" />
  36. <u-input :disabled="true" style="width: 70rpx;" v-model="projectQuantitySiteUnit"/>
  37. </view>
  38. </u-form-item>
  39. </u-form>
  40. </view>
  41. <view class="mt-3">
  42. <u-button @click="submit" type="primary" shape="circle">提交</u-button>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. form: {
  51. projectQuantityId: '',
  52. projectQuantityStart: 0,
  53. projectQuantityEnd: 0
  54. },
  55. projectQuantitySiteUnit: '无',
  56. projectQuantityList: [],
  57. projectQuantityUnitMap: {},
  58. rules: {
  59. projectQuantityId: [
  60. {
  61. required: true,
  62. message: '请选择作业名称',
  63. trigger: ['change']
  64. }
  65. ],
  66. projectQuantityStart: [
  67. {
  68. required: true,
  69. message: '请输入起始值',
  70. trigger: ['blur', 'change']
  71. }
  72. ],
  73. projectQuantityEnd: [
  74. {
  75. required: true,
  76. message: '请输入结束值',
  77. trigger: ['blur', 'change']
  78. }
  79. ]
  80. },
  81. id: '' // 列表 id
  82. };
  83. },
  84. onShow() {
  85. // 获取设备与仓库
  86. this.initData();
  87. },
  88. onLoad(options) {
  89. this.projectQuantityUnitMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.FILL_PROJECT_QUANTITY_UNIT)
  90. },
  91. // watch: {
  92. // 'form.projectQuantityStart': {
  93. // handler(newVal, oldVal) {
  94. // console.log(newVal, oldVal)
  95. // if (!newVal && newVal !== 0) {
  96. // this.form.projectQuantityStart = 0
  97. // }
  98. // },
  99. // deep: true
  100. // }
  101. // },
  102. methods: {
  103. initData() {
  104. this.$Http.queryFillProjectQuantityDeptProject({ filter: 1 }).then(res => {
  105. this.projectQuantityList = res.data
  106. })
  107. },
  108. numBlur(e, type) {
  109. // console.log(!e, type === 'projectQuantityStart')
  110. // if (!e) {
  111. // if (type === 'projectQuantityStart') {
  112. // this.$set(this.form, 'projectQuantityStart', 0);
  113. // } else {
  114. // this.form.projectQuantityEnd = 0
  115. // }
  116. // }
  117. },
  118. changeProjectQuantity(value, data) {
  119. console.log(value, data)
  120. this.projectQuantitySiteUnit = this.projectQuantityUnitMap[data.siteUnit]
  121. },
  122. submit() {
  123. this.$refs.uForm.validate(valid => {
  124. const sbRunList = uni.getStorageSync('sb-run-list');
  125. if (valid) {
  126. if (!this.form.projectQuantityStart && this.form.projectQuantityStart !== 0) {
  127. uni.showToast({ title: '起始值不能为空', icon: 'none' })
  128. return
  129. }
  130. if (!this.form.projectQuantityEnd && this.form.projectQuantityEnd !== 0) {
  131. uni.showToast({ title: '结束值不能为空', icon: 'none' })
  132. return
  133. }
  134. this.$Http.batchUpdateProject({ ...this.form, targetIds: sbRunList }).then(res => {
  135. uni.removeStorageSync('sb-run-list')
  136. uni.redirectTo({
  137. url: '/pages/running/running'
  138. });
  139. }).catch(() => {
  140. })
  141. }
  142. });
  143. }
  144. },
  145. onReady() {
  146. this.$refs.uForm.setRules(this.rules);
  147. }
  148. };
  149. </script>
  150. <style lang="less">
  151. page {
  152. background-color: #f4f4f4;
  153. }
  154. </style>