type-business-edit.vue 9.8 KB

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