type-business-edit.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="top">
  5. <text class="title">{{itemType.name}}</text>
  6. </view>
  7. <view class="item-line">
  8. 基本信息
  9. </view>
  10. <view class="item">
  11. <view class="l"><text style="color: red;">*</text>车牌号:</view>
  12. <view class="r">
  13. <u-input placeholder="请填写车牌号" v-model="form.carNo" />
  14. </view>
  15. </view>
  16. <view class="item">
  17. <view class="l"><text style="color: red;">*</text>车辆类型:</view>
  18. <view class="r">
  19. <picker class="p-picker" id="qy" @change="bindPickerChange($event)" :value="type.index"
  20. :range="type.list" range-key="name">
  21. <text class="p-text">{{type.list[type.index]}}</text>
  22. <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
  23. </picker>
  24. </view>
  25. </view>
  26. <view class="item">
  27. <view class="l"><text style="color: red;">*</text>车辆规格:</view>
  28. <view class="r">
  29. <u-input placeholder="请填写车辆规格" v-model="form.carSize" />
  30. </view>
  31. </view>
  32. <view class="item" v-if="type.index==1">
  33. <view class="l">载重(kg):</view>
  34. <view class="r">
  35. <u-input placeholder="请填写车辆载重" v-model="form.carWeight" />
  36. </view>
  37. </view>
  38. <view class="item-line">
  39. 收费明细<text style="color: red;">(总共{{totalPrice}}元)</text>
  40. </view>
  41. <u-checkbox-group v-model="checkList" placement="column">
  42. <uni-list v-for="item in itemType.items">
  43. <uni-list-item style="display: inline;" :title="item.itemName" :note="item.price+''+item.unit">
  44. <template v-slot:header>
  45. <u-checkbox :name="item.id" :disabled="item.need==1" style="display: inline;">
  46. </u-checkbox>
  47. </template>
  48. <template v-slot:footer>
  49. <div style="position: absolute;right: 230rpx;top: 65rpx;">
  50. <u-number-box :disabled="item.inc==0" v-model="item.num">
  51. <view slot="minus" class="minus">
  52. <u-icon name="minus" size="12"></u-icon>
  53. </view>
  54. <text slot="input" style="width: 50px;text-align: center;"
  55. class="input">{{item.num}}</text>
  56. <view slot="plus" class="plus">
  57. <u-icon name="plus" size="12"></u-icon>
  58. </view>
  59. </u-number-box>
  60. </div>
  61. <u-button v-show="item.needRemark" @click="openRemarkFn(item)" style="width: 50px;"
  62. type="primary" size="mini" text="备注"></u-button>
  63. </template>
  64. </uni-list-item>
  65. </uni-list>
  66. </u-checkbox-group>
  67. </view>
  68. <view v-if="!form.adminConfirmInput">
  69. <u-button type="primary" text="修改" @click="saveFn"></u-button>
  70. </view>
  71. <!-- ---------------------------------------------------------- -->
  72. <view class="bottom-safety"></view>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. showRemark: false,
  80. type: {
  81. index: 1,
  82. list: ['空车', '载货']
  83. },
  84. obj: null,
  85. form: {
  86. carNo: '',
  87. carSize: '',
  88. carWeight: ''
  89. },
  90. list: [],
  91. checkList: [],
  92. businessItems: [],
  93. itemType: {
  94. id: '',
  95. name: '',
  96. items: []
  97. }
  98. }
  99. },
  100. computed: {
  101. totalPrice() {
  102. let items = this.itemType.items;
  103. let checkList = this.checkList;
  104. items = items.filter(obj => checkList.indexOf(obj.id) !== -1);
  105. let price = 0;
  106. for (let i in items) {
  107. let item = items[i];
  108. price = price + item.price * item.num;
  109. }
  110. return price;
  111. }
  112. },
  113. onLoad(options) {
  114. this.form.id = options.id;
  115. this.getOtherBusinessById();
  116. let that = this;
  117. uni.$on('getRemark', data => {
  118. that.$nextTick(function() {
  119. let items = that.itemType.items;
  120. items.filter(obj => obj.id == data.itemId)[0].remark = data.remark;
  121. })
  122. })
  123. },
  124. onBackPress() {
  125. this.$common.to('/pages/onely-disinfect/Index');
  126. return true;
  127. },
  128. methods: {
  129. openRemarkFn(data) {
  130. this.$common.to('/pages/onely-disinfect/add-remark?itemId=' + data.id + '&title=' + data.itemName +
  131. '&remark=' + data.remark + '&mustRemark=' + data.mustRemark)
  132. },
  133. closeFn() {
  134. this.$refs.popup.close()
  135. },
  136. getItemType() {
  137. this.$api.getItemType({
  138. id: this.itemType.id
  139. }).then(resp => {
  140. let data = resp.data;
  141. this.itemType = data;
  142. let items = data.items;
  143. let businessItems = this.businessItems;
  144. items.forEach(obj => {
  145. businessItems.forEach(item => {
  146. if (obj.id == item.itemId) {
  147. obj.remark = item.remark;
  148. obj.num = item.num;
  149. }
  150. })
  151. })
  152. })
  153. },
  154. bindPickerChange(e) {
  155. let index = e.detail.value;
  156. this.type.index = index //当前picker选中的值
  157. },
  158. saveFn() {
  159. if (!this.form.carNo) {
  160. this.$common.toast('请输入车牌号')
  161. return;
  162. }
  163. if (!this.$common.isNum(this.form.carSize)) {
  164. this.$common.toast('请输入正确的规格')
  165. return;
  166. }
  167. if (this.type.index == 1 && !this.$common.isNum(this.form.carWeight)) {
  168. this.$common.toast('请输正确的载重')
  169. return;
  170. }
  171. let itemList = this.itemType.items;
  172. let checkList = this.checkList;
  173. let list = itemList.filter(obj => checkList.indexOf(obj.id) !== -1);
  174. this.form.itemTypeId = this.itemType.id;
  175. this.form.items = list;
  176. this.form.carType = this.type.list[this.type.index]
  177. let that = this;
  178. let content = '确认修改该业务'
  179. uni.showModal({
  180. title: '提示',
  181. content: content,
  182. success(res) {
  183. if (res.confirm) {
  184. that.editFn()
  185. }
  186. }
  187. })
  188. },
  189. getOtherBusinessById() {
  190. this.$api.getOtherBusinessById({
  191. id: this.form.id
  192. }).then(resp => {
  193. let data = resp.data;
  194. this.form = data;
  195. this.businessItems = data.items;
  196. this.checkList = data.items.map(obj => obj.itemId);
  197. this.itemType.id = data.itemTypeId;
  198. this.type.index = this.type.list.indexOf(data.carType)
  199. this.getItemType();
  200. })
  201. },
  202. editFn() {
  203. this.$api.editCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  204. if (resp.code == 200) {
  205. this.$common.toast('修改成功');
  206. setTimeout(() => {
  207. this.$common.to('/pages/onely-disinfect/Index')
  208. }, 1500)
  209. }
  210. })
  211. }
  212. },
  213. }
  214. </script>
  215. <style lang="scss">
  216. page {
  217. background-color: #fff;
  218. }
  219. .hs-item {
  220. text-align: center;
  221. }
  222. .item-line {
  223. color: #a2a2a2;
  224. padding: 5px 0 10px 29px;
  225. border-bottom: 1px solid #E5E5E5;
  226. }
  227. .hj {
  228. padding: 50rpx;
  229. font-size: 40rpx;
  230. color: red;
  231. font-weight: bold;
  232. }
  233. .save-btn {
  234. background-color: #ff4200;
  235. height: 88rpx;
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. margin: 60rpx;
  240. color: #fff;
  241. font-size: 30rpx;
  242. font-weight: bold;
  243. border-radius: 10rpx;
  244. }
  245. @import '@/common/common.scss'
  246. </style>