type-business-edit.vue 8.0 KB

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