type-business.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. <picker class="p-picker" id="qy" @change="bindPickerChange($event)" :value="type.index"
  14. :range="type.list" range-key="name">
  15. <text class="p-text">{{type.list[type.index]}}</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. <u-input placeholder="请填写车辆规格" v-model="form.carSize" />
  30. </view>
  31. </view>
  32. <view class="item" v-if="type.index==1">
  33. <view class="l">车辆载重:</view>
  34. <view class="r">
  35. <u-input placeholder="请填写车辆载重" v-model="form.carWeight" />
  36. </view>
  37. </view>
  38. <view class="item-line">
  39. 收费明细
  40. </view>
  41. <view class="item" v-for="item in itemList" :key="item.id">
  42. <view class="l" style="flex: 6;">{{item.itemName}}:
  43. </view>
  44. <view class="r">
  45. <view style="margin-left: 20rpx;">
  46. {{item.price}}元
  47. </view>
  48. </view>
  49. </view>
  50. <u-checkbox-group v-for="item in itemType.items" placement="column">
  51. <uni-list>
  52. <uni-list-item :title="item.itemName" :note="item.price+''+item.unit">
  53. <template v-slot:footer>
  54. <u-checkbox :name="item.id" :checked="item.need">
  55. </u-checkbox>
  56. </template>
  57. </uni-list-item>
  58. </uni-list>
  59. </u-checkbox-group>
  60. </view>
  61. <view v-if="!form.adminConfirmInput">
  62. <u-button type="primary" v-if="!obj" text="保存" @click="saveFn"></u-button>
  63. <!-- <u-button type="primary" v-if="obj" text="修改" @click="saveFn"></u-button> -->
  64. <u-button type="primary" v-if="obj" text="确认账单" @click="confirmFn" style="margin-top: 20rpx;"></u-button>
  65. <u-button type="info" text="重置" @click="resetFn" style="margin-top: 20rpx;"></u-button>
  66. </view>
  67. <!-- ---------------------------------------------------------- -->
  68. <view class="bottom-safety"></view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. type: {
  76. index: 0,
  77. list: ['空车', '载货']
  78. },
  79. obj: null,
  80. form: {
  81. carNo: ''
  82. },
  83. itemList: [],
  84. list: [],
  85. itemType: {
  86. id: '',
  87. name: '',
  88. items: []
  89. }
  90. }
  91. },
  92. onLoad(options) {
  93. let typeId = options.typeId;
  94. this.itemType.id = typeId;
  95. this.getItemType();
  96. },
  97. mounted() {},
  98. onBackPress() {
  99. this.$common.to('/pages/onely-disinfect/Index');
  100. return true;
  101. },
  102. methods: {
  103. getItemType() {
  104. this.$api.getItemType({
  105. id: this.itemType.id
  106. }).then(resp => {
  107. this.itemType = resp.data;
  108. })
  109. },
  110. bindPickerChange(e) {
  111. let index = e.detail.value;
  112. this.type.index = index //当前picker选中的值
  113. if (index == 0) {
  114. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头车厢') !== -1)
  115. } else {
  116. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头消杀') !== -1)
  117. }
  118. },
  119. getTypeList() {
  120. this.$api.getItemList({
  121. business: 0
  122. }).then(resp => {
  123. let list = resp.data;
  124. let itemList = [];
  125. for (let i in list) {
  126. let item = list[i];
  127. itemList.push(item.items[0]);
  128. }
  129. this.list = itemList;
  130. this.itemList = itemList.filter(obj => obj.itemName.indexOf('车头车厢') !== -1);
  131. if (this.obj) {
  132. this.form.carNo = this.obj.carNo;
  133. this.form.businessCarId = this.obj.businessCarId;
  134. this.form.adminConfirmInput = this.obj.adminConfirmInput;
  135. this.form.id = this.obj.id;
  136. let index = this.type.list.indexOf(this.obj.goodsName);
  137. this.type.index = index
  138. if (index == 0) {
  139. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头车厢') !== -1)
  140. } else {
  141. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头消杀') !== -1)
  142. }
  143. }
  144. })
  145. },
  146. resetFn() {
  147. this.form.carNo = '';
  148. this.type.index = 0;
  149. this.itemList = this.list;
  150. },
  151. saveFn() {
  152. if (!this.form.carNo) {
  153. this.$common.toast('请输入车牌号')
  154. return;
  155. }
  156. this.form.itemJson = JSON.stringify(this.itemList);
  157. this.form.carType = this.type.list[this.type.index]
  158. let that = this;
  159. let content = this.obj ? '确认修改该业务?' : '确认录入该车辆的消杀业务?'
  160. uni.showModal({
  161. title: '提示',
  162. content: content,
  163. success(res) {
  164. if (res.confirm) {
  165. if (!that.obj) {
  166. that.addFn();
  167. } else {
  168. that.editFn()
  169. }
  170. }
  171. }
  172. })
  173. },
  174. addFn() {
  175. this.$api.addCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  176. if (resp.code == 200) {
  177. this.$common.to('/pages/onely-disinfect/addSuccess')
  178. }
  179. })
  180. },
  181. confirmFn() {
  182. let that = this;
  183. uni.showModal({
  184. title: '提示',
  185. content: '是否确认该账单?',
  186. success(res) {
  187. if (res.confirm) {
  188. that.$api.adminConfirm({
  189. ids: that.form.id
  190. }).then(resp => {
  191. if (resp.code == 200) {
  192. that.$common.toast('已确认');
  193. setTimeout(() => {
  194. that.$common.to('/pages/onely-disinfect/Index')
  195. }, 1500)
  196. }
  197. })
  198. }
  199. }
  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>