disinfect-Index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="top">
  5. <text class="title">灵活业务</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-line">
  27. 业务项
  28. </view>
  29. <view class="item" v-for="item in itemList" :key="item.id">
  30. <view class="l" style="flex: 6;">{{item.itemName}}:
  31. </view>
  32. <view class="r">
  33. <view style="margin-left: 20rpx;">
  34. {{item.price}}元
  35. </view>
  36. </view>
  37. </view>
  38. <view class="item">
  39. <view class="l">停车费:
  40. </view>
  41. <view class="r">
  42. <view style="margin-left: 20rpx;">
  43. 30元
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="!form.adminConfirmInput">
  49. <u-button type="primary" v-if="!obj" text="保存" @click="saveFn"></u-button>
  50. <!-- <u-button type="primary" v-if="obj" text="修改" @click="saveFn"></u-button> -->
  51. <u-button type="primary" v-if="obj" text="确认账单" @click="confirmFn" style="margin-top: 20rpx;"></u-button>
  52. <u-button type="info" text="重置" @click="resetFn" style="margin-top: 20rpx;"></u-button>
  53. </view>
  54. <!-- ---------------------------------------------------------- -->
  55. <view class="bottom-safety"></view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. type: {
  63. index: 0,
  64. list: ['空车', '载货']
  65. },
  66. obj: null,
  67. form: {
  68. carNo: ''
  69. },
  70. itemList: [],
  71. list: []
  72. }
  73. },
  74. onLoad(options) {
  75. let data = options.json;
  76. if (data) {
  77. this.obj = JSON.parse(options.json)
  78. }
  79. },
  80. mounted() {
  81. this.getTypeList();
  82. },
  83. onBackPress() {
  84. this.$common.to('/pages/onely-disinfect/Index');
  85. return true;
  86. },
  87. methods: {
  88. bindPickerChange(e) {
  89. let index = e.detail.value;
  90. this.type.index = index //当前picker选中的值
  91. if (index == 0) {
  92. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头车厢') !== -1)
  93. } else {
  94. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头消杀') !== -1)
  95. }
  96. },
  97. getTypeList() {
  98. this.$api.getItemList({
  99. business: 0
  100. }).then(resp => {
  101. let list = resp.data;
  102. let itemList = [];
  103. for (let i in list) {
  104. let item = list[i];
  105. itemList.push(item.items[0]);
  106. }
  107. this.list = itemList;
  108. this.itemList = itemList.filter(obj => obj.itemName.indexOf('车头车厢') !== -1);
  109. if (this.obj) {
  110. this.form.carNo = this.obj.carNo;
  111. this.form.businessCarId = this.obj.businessCarId;
  112. this.form.adminConfirmInput = this.obj.adminConfirmInput;
  113. this.form.id = this.obj.id;
  114. let index = this.type.list.indexOf(this.obj.goodsName);
  115. this.type.index = index
  116. if (index == 0) {
  117. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头车厢') !== -1)
  118. } else {
  119. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头消杀') !== -1)
  120. }
  121. }
  122. })
  123. },
  124. resetFn() {
  125. this.form.carNo = '';
  126. this.type.index = 0;
  127. this.itemList = this.list;
  128. },
  129. saveFn() {
  130. if (!this.form.carNo) {
  131. this.$common.toast('请输入车牌号')
  132. return;
  133. }
  134. this.form.itemJson = JSON.stringify(this.itemList);
  135. this.form.carType = this.type.list[this.type.index]
  136. let that = this;
  137. let content = this.obj ? '确认修改该业务?' : '确认录入该车辆的消杀业务?'
  138. uni.showModal({
  139. title: '提示',
  140. content: content,
  141. success(res) {
  142. if (res.confirm) {
  143. if (!that.obj) {
  144. that.addFn();
  145. } else {
  146. that.editFn()
  147. }
  148. }
  149. }
  150. })
  151. },
  152. addFn() {
  153. this.$api.addCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  154. if (resp.code == 200) {
  155. this.$common.to('/pages/onely-disinfect/addSuccess')
  156. }
  157. })
  158. },
  159. confirmFn() {
  160. let that = this;
  161. uni.showModal({
  162. title: '提示',
  163. content: '是否确认该账单?',
  164. success(res) {
  165. if (res.confirm) {
  166. that.$api.adminConfirm({
  167. ids: that.form.id
  168. }).then(resp => {
  169. if (resp.code == 200) {
  170. that.$common.toast('已确认');
  171. setTimeout(() => {
  172. that.$common.to('/pages/onely-disinfect/Index')
  173. }, 1500)
  174. }
  175. })
  176. }
  177. }
  178. })
  179. },
  180. editFn() {
  181. this.$api.editCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  182. if (resp.code == 200) {
  183. this.$common.toast('修改成功');
  184. setTimeout(() => {
  185. this.$common.to('/pages/onely-disinfect/Index')
  186. }, 1500)
  187. }
  188. })
  189. }
  190. },
  191. }
  192. </script>
  193. <style lang="scss">
  194. page {
  195. background-color: #fff;
  196. }
  197. .hs-item {
  198. text-align: center;
  199. }
  200. .item-line {
  201. color: #a2a2a2;
  202. padding: 5px 0 10px 29px;
  203. border-bottom: 1px solid #E5E5E5;
  204. }
  205. .hj {
  206. padding: 50rpx;
  207. font-size: 40rpx;
  208. color: red;
  209. font-weight: bold;
  210. }
  211. .save-btn {
  212. background-color: #ff4200;
  213. height: 88rpx;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. margin: 60rpx;
  218. color: #fff;
  219. font-size: 30rpx;
  220. font-weight: bold;
  221. border-radius: 10rpx;
  222. }
  223. @import '@/common/common.scss'
  224. </style>