disinfect-Index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. console.log(this.form)
  79. }
  80. },
  81. mounted() {
  82. this.getTypeList();
  83. },
  84. onBackPress() {
  85. this.$common.to('/pages/onely-disinfect/Index');
  86. return true;
  87. },
  88. methods: {
  89. bindPickerChange(e) {
  90. let index = e.detail.value;
  91. this.type.index = index //当前picker选中的值
  92. if (index == 0) {
  93. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头车厢') !== -1)
  94. } else {
  95. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头消杀') !== -1)
  96. }
  97. },
  98. getTypeList() {
  99. this.$api.getItemList({
  100. business: 0
  101. }).then(resp => {
  102. let list = resp.data;
  103. let itemList = [];
  104. for (let i in list) {
  105. let item = list[i];
  106. itemList.push(item.items[0]);
  107. }
  108. this.list = itemList;
  109. this.itemList = itemList.filter(obj => obj.itemName.indexOf('车头车厢') !== -1);
  110. if (this.obj) {
  111. this.form.carNo = this.obj.carNo;
  112. this.form.businessCarId = this.obj.businessCarId;
  113. this.form.adminConfirmInput = this.obj.adminConfirmInput;
  114. this.form.id = this.obj.id;
  115. let index = this.type.list.indexOf(this.obj.goodsName);
  116. this.type.index = index
  117. if (index == 0) {
  118. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头车厢') !== -1)
  119. } else {
  120. this.itemList = this.list.filter(obj => obj.itemName.indexOf('车头消杀') !== -1)
  121. }
  122. }
  123. })
  124. },
  125. resetFn() {
  126. this.form.carNo = '';
  127. this.type.index = 0;
  128. this.itemList = this.list;
  129. },
  130. saveFn() {
  131. if (!this.form.carNo) {
  132. this.$common.toast('请输入车牌号')
  133. return;
  134. }
  135. this.form.itemJson = JSON.stringify(this.itemList);
  136. this.form.carType = this.type.list[this.type.index]
  137. let that = this;
  138. let content = this.obj ? '确认修改该业务?' : '确认录入该车辆的消杀业务?'
  139. uni.showModal({
  140. title: '提示',
  141. content: content,
  142. success(res) {
  143. if (res.confirm) {
  144. if (!that.obj) {
  145. that.addFn();
  146. } else {
  147. that.editFn()
  148. }
  149. }
  150. }
  151. })
  152. },
  153. addFn() {
  154. this.$api.addCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  155. if (resp.code == 200) {
  156. this.$common.to('/pages/onely-disinfect/addSuccess')
  157. }
  158. })
  159. },
  160. confirmFn() {
  161. let that = this;
  162. uni.showModal({
  163. title: '提示',
  164. content: '是否确认该账单?',
  165. success(res) {
  166. if (res.confirm) {
  167. that.$api.adminConfirm({
  168. ids: that.form.id
  169. }).then(resp => {
  170. if (resp.code == 200) {
  171. that.$common.toast('已确认');
  172. setTimeout(() => {
  173. that.$common.to('/pages/onely-disinfect/Index')
  174. }, 1500)
  175. }
  176. })
  177. }
  178. }
  179. })
  180. },
  181. editFn() {
  182. this.$api.editCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  183. if (resp.code == 200) {
  184. this.$common.toast('修改成功');
  185. setTimeout(() => {
  186. this.$common.to('/pages/onely-disinfect/Index')
  187. }, 1500)
  188. }
  189. })
  190. }
  191. },
  192. }
  193. </script>
  194. <style lang="scss">
  195. page {
  196. background-color: #fff;
  197. }
  198. .hs-item {
  199. text-align: center;
  200. }
  201. .item-line {
  202. color: #a2a2a2;
  203. padding: 5px 0 10px 29px;
  204. border-bottom: 1px solid #E5E5E5;
  205. }
  206. .hj {
  207. padding: 50rpx;
  208. font-size: 40rpx;
  209. color: red;
  210. font-weight: bold;
  211. }
  212. .save-btn {
  213. background-color: #ff4200;
  214. height: 88rpx;
  215. display: flex;
  216. justify-content: center;
  217. align-items: center;
  218. margin: 60rpx;
  219. color: #fff;
  220. font-size: 30rpx;
  221. font-weight: bold;
  222. border-radius: 10rpx;
  223. }
  224. @import '@/common/common.scss'
  225. </style>