type-business.vue 7.3 KB

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