type-business.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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
  52. slot="minus"
  53. class="minus">
  54. <u-icon
  55. name="minus"
  56. size="12"
  57. ></u-icon>
  58. </view>
  59. <text
  60. slot="input"
  61. style="width: 50px;text-align: center;"
  62. class="input"
  63. >{{item.num}}</text>
  64. <view
  65. slot="plus"
  66. class="plus"
  67. >
  68. <u-icon
  69. name="plus"
  70. size="12"
  71. ></u-icon>
  72. </view>
  73. </u-number-box>
  74. </div>
  75. <u-button v-show="item.needRemark" @click="openRemarkFn(item)" style="width: 50px;"
  76. type="primary" size="mini" text="备注"></u-button>
  77. </template>
  78. </uni-list-item>
  79. </uni-list>
  80. </u-checkbox-group>
  81. </view>
  82. <view v-if="!form.adminConfirmInput">
  83. <u-button type="primary" v-if="!obj" text="保存" @click="saveFn"></u-button>
  84. <u-button type="primary" v-if="obj" text="确认账单" @click="confirmFn" style="margin-top: 20rpx;"></u-button>
  85. </view>
  86. <!-- ---------------------------------------------------------- -->
  87. <view class="bottom-safety"></view>
  88. </view>
  89. </template>
  90. <script>
  91. export default {
  92. data() {
  93. return {
  94. showRemark: false,
  95. type: {
  96. index: 1,
  97. list: ['空车', '载货']
  98. },
  99. obj: null,
  100. form: {
  101. carNo: '',
  102. carSize: '',
  103. carWeight: ''
  104. },
  105. list: [],
  106. checkList: [],
  107. itemType: {
  108. id: '',
  109. name: '',
  110. items: []
  111. }
  112. }
  113. },
  114. computed: {
  115. totalPrice() {
  116. let items = this.itemType.items;
  117. let checkList = this.checkList;
  118. items = items.filter(obj => checkList.indexOf(obj.id) !== -1);
  119. let price = 0;
  120. for (let i in items) {
  121. let item = items[i];
  122. price = price + item.price * item.num;
  123. }
  124. return price;
  125. }
  126. },
  127. onLoad(options) {
  128. let typeId = options.typeId;
  129. this.itemType.id = typeId;
  130. this.getItemType();
  131. let that = this;
  132. uni.$on('getRemark', data => {
  133. that.$nextTick(function() {
  134. let items = that.itemType.items;
  135. items.filter(obj => obj.id == data.itemId)[0].remark = data.remark;
  136. })
  137. })
  138. },
  139. onBackPress() {
  140. this.$common.to('/pages/onely-disinfect/Index');
  141. return true;
  142. },
  143. methods: {
  144. openRemarkFn(data) {
  145. this.$common.to('/pages/onely-disinfect/add-remark?itemId=' + data.id + '&title=' + data.itemName +
  146. '&remark=' + data.remark + '&mustRemark=' + data.mustRemark)
  147. },
  148. closeFn() {
  149. this.$refs.popup.close()
  150. },
  151. getItemType() {
  152. this.$api.getItemType({
  153. id: this.itemType.id
  154. }).then(resp => {
  155. let data = resp.data;
  156. this.itemType = data;
  157. let items = data.items;
  158. this.checkList = items.filter(obj => obj.need == 1).map(obj => obj.id)
  159. })
  160. },
  161. bindPickerChange(e) {
  162. let index = e.detail.value;
  163. console.log(index)
  164. this.type.index = index //当前picker选中的值
  165. },
  166. saveFn() {
  167. if (!this.form.carNo) {
  168. this.$common.toast('请输入车牌号')
  169. return;
  170. }
  171. if (!this.$common.isNum(this.form.carSize)) {
  172. this.$common.toast('请输入正确的规格')
  173. return;
  174. }
  175. if (this.type.index == 1 && !this.$common.isNum(this.form.carWeight)) {
  176. this.$common.toast('请输正确的载重')
  177. return;
  178. }
  179. let itemList = this.itemType.items;
  180. let checkList = this.checkList;
  181. let list = itemList.filter(obj => checkList.indexOf(obj.id) !== -1);
  182. this.form.itemTypeId = this.itemType.id;
  183. this.form.items = list;
  184. this.form.carType = this.type.list[this.type.index]
  185. let that = this;
  186. let content = this.obj ? '确认修改该业务?' : '确认录入该车辆的业务?'
  187. uni.showModal({
  188. title: '提示',
  189. content: content,
  190. success(res) {
  191. if (res.confirm) {
  192. if (!that.obj) {
  193. that.addFn();
  194. } else {
  195. that.editFn()
  196. }
  197. }
  198. }
  199. })
  200. },
  201. addFn() {
  202. this.$api.addCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  203. if (resp.code == 200) {
  204. this.$common.to('/pages/onely-disinfect/addSuccess?typeId=' + this.itemType.id)
  205. }
  206. })
  207. },
  208. confirmFn() {
  209. let that = this;
  210. uni.showModal({
  211. title: '提示',
  212. content: '是否确认该账单?',
  213. success(res) {
  214. if (res.confirm) {
  215. that.$api.adminConfirm({
  216. ids: that.form.id
  217. }).then(resp => {
  218. if (resp.code == 200) {
  219. that.$common.toast('已确认');
  220. setTimeout(() => {
  221. that.$common.to('/pages/onely-disinfect/Index')
  222. }, 1500)
  223. }
  224. })
  225. }
  226. }
  227. })
  228. },
  229. editFn() {
  230. this.$api.editCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
  231. if (resp.code == 200) {
  232. this.$common.toast('修改成功');
  233. setTimeout(() => {
  234. this.$common.to('/pages/onely-disinfect/Index')
  235. }, 1500)
  236. }
  237. })
  238. }
  239. },
  240. }
  241. </script>
  242. <style lang="scss">
  243. page {
  244. background-color: #fff;
  245. }
  246. .hs-item {
  247. text-align: center;
  248. }
  249. .item-line {
  250. color: #a2a2a2;
  251. padding: 5px 0 10px 29px;
  252. border-bottom: 1px solid #E5E5E5;
  253. }
  254. .hj {
  255. padding: 50rpx;
  256. font-size: 40rpx;
  257. color: red;
  258. font-weight: bold;
  259. }
  260. .save-btn {
  261. background-color: #ff4200;
  262. height: 88rpx;
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. margin: 60rpx;
  267. color: #fff;
  268. font-size: 30rpx;
  269. font-weight: bold;
  270. border-radius: 10rpx;
  271. }
  272. @import '@/common/common.scss'
  273. </style>