type-business-edit.vue 8.7 KB

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