project.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view class="project">
  3. <view class="top">
  4. </view>
  5. <view class="head">
  6. <span class="cuIcon-back" @click="back"></span>
  7. <view class="case">
  8. <!-- 选择服务项目 -->
  9. {{type==0?'修改服务项目':'选择服务项目'}}
  10. </view>
  11. </view>
  12. <view class="content">
  13. <view class="option" v-for="(item,index) in projectList" :key="index">
  14. <view class="name">
  15. <span>{{item.itemName}}</span>
  16. <u-switch v-model="item.checked" size="50rpx" @change="change(item)"></u-switch>
  17. </view>
  18. <view class="price" v-if="item.checked">
  19. <span>服务价格</span>
  20. <span><u-input v-model="item.itemMoney" type="number" @input="handleInput(item)" @blur="validateInput(item)"
  21. style="width: 260rpx;height: 62rpx;background-color: #f7f8fc;padding: 0rpx 20rpx;margin-right: 16rpx;" />元</span>
  22. </view>
  23. <view class="explain" v-if="item.checked">
  24. <span>服务说明</span>
  25. <view class="text">
  26. <textarea v-model="item.itemContent" placeholder="请简要说明收费项目内容" maxlength="100" cols="30" rows="10"
  27. style="width: 100%;height: 100%;padding: 12rpx 16rpx;font-size: 26rpx;"></textarea>
  28. <span>{{item.itemContent.length}}/100</span>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="btn_box">
  34. <view class="customer" @click="back">
  35. 取消
  36. </view>
  37. <view class="accept" @click="submit">
  38. 确定
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. checkType: '',
  48. taskId: '',
  49. orderNo: '',
  50. productName: '',
  51. subOrderId: '', //修改用
  52. projectList: [{
  53. itemName: '车辆维修费',
  54. checked: false,
  55. delFlag: '',
  56. itemMoney: null,
  57. itemContent: ''
  58. },
  59. {
  60. itemName: '喷漆费',
  61. checked: false,
  62. delFlag: '',
  63. itemMoney: null,
  64. itemContent: ''
  65. },
  66. {
  67. itemName: '零配件',
  68. checked: false,
  69. delFlag: '',
  70. itemMoney: null,
  71. itemContent: ''
  72. },
  73. {
  74. itemName: '车辆清洁费',
  75. checked: false,
  76. delFlag: '',
  77. itemMoney: null,
  78. itemContent: ''
  79. },
  80. {
  81. itemName: '其他费用',
  82. checked: false,
  83. delFlag: '',
  84. itemMoney: null,
  85. itemContent: ''
  86. }
  87. ],
  88. type: '',
  89. editId: ''
  90. }
  91. },
  92. methods: {
  93. //返回
  94. back() {
  95. // uni.navigateBack();
  96. // uni.navigateBack({
  97. // delta: 1
  98. // });
  99. uni.switchTab({
  100. url: '/pages/order/index'
  101. })
  102. },
  103. //关闭时置空
  104. change(item) {
  105. console.log(item)
  106. if (!item.checked) {
  107. item.itemContent = ''
  108. item.itemMoney = ''
  109. }
  110. },
  111. // 实时输入时校验(防止用户输入非法字符)
  112. handleInput(item) {
  113. let value = item.itemMoney.toString();
  114. // 限制整数部分最多8位
  115. let parts = value.split('.');
  116. if (parts[0].length > 8) {
  117. parts[0] = parts[0].slice(0, 8);
  118. }
  119. // 限制小数部分最多两位
  120. if (parts[1]) {
  121. parts[1] = parts[1].slice(0, 2);
  122. }
  123. // 合并整数和小数部分,确保输入的格式符合要求
  124. item.itemMoney = parts.join('.');
  125. },
  126. //输入金额
  127. validateInput(item) {
  128. if (Number(item.itemMoney) <= 0) {
  129. uni.showToast({
  130. title: '金额必须大于0',
  131. icon: 'none'
  132. });
  133. item.itemMoney = ''; // 清空或设置为默认最小值
  134. }
  135. },
  136. submit() {
  137. let list = []
  138. this.projectList.forEach(item => {
  139. if (item.checked ) {
  140. item.delFlag = 0
  141. } else {
  142. item.delFlag = 1
  143. item.itemMoney = 0
  144. }
  145. list.push({
  146. delFlag: item.delFlag,
  147. itemContent: item.itemContent,
  148. itemMoney:item.itemMoney ,
  149. itemName: item.itemName
  150. })
  151. })
  152. console.log(list)
  153. let data = {
  154. checkType: this.checkType,
  155. taskId: this.taskId,
  156. orderNo: this.orderNo,
  157. orderName: this.productName,
  158. merchantId: uni.getStorageSync('login_user_info').merchantId,
  159. id: this.editId,
  160. serveType:this.checkType<20?'01':'02',
  161. // id : uni.getStorageSync('login_user_info').id,
  162. addMerchantServiceVoList: list
  163. }
  164. this.$http.post("/ts/merchant/addPaidService", data).then(res => {
  165. console.log(res)
  166. if (res.data.code == 200) {
  167. // this.$emit('upSuccess')
  168. uni.showToast({
  169. icon: 'none',
  170. title: '添加成功'
  171. })
  172. this.back()
  173. }else{
  174. uni.showToast({
  175. icon: 'none',
  176. title: res.data.message
  177. })
  178. }
  179. })
  180. },
  181. //回显
  182. getChange() {
  183. this.$http.get("/ts/merchant/servicesDetails?subOrderId=" + this.orderNo).then(res => {
  184. if (res.data.code == 200) {
  185. this.editId = res.data.result.id
  186. res.data.result.serviceDetails.forEach(item => {
  187. item.delFlag == 0 ? item.checked = true : item.checked = false
  188. })
  189. this.projectList = res.data.result.serviceDetails
  190. }
  191. })
  192. }
  193. },
  194. onLoad(options) {
  195. console.log(options)
  196. this.checkType = options.checkType
  197. this.taskId = options.taskId
  198. this.orderNo = options.orderNo
  199. this.productName = options.productName
  200. this.type = options.type
  201. if (this.type == 0) {
  202. this.getChange()
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. .project {
  209. width: 100vw;
  210. height: 100vh;
  211. background: #F8F8FA;
  212. display: flex;
  213. flex-direction: column;
  214. // overflow-y: auto;
  215. /*#ifdef APP-PLUS*/
  216. .top {
  217. width: 100%;
  218. height: var(--status-bar-height);
  219. background: #FFFFFF;
  220. }
  221. /*#endif*/
  222. .head {
  223. width: 100%;
  224. height: 112rpx;
  225. padding: 20rpx;
  226. display: flex;
  227. align-items: center;
  228. background: #FFFFFF;
  229. position: relative;
  230. border-bottom: 1px solid #F0F3F5;
  231. .cuIcon-back {
  232. font-size: 40rpx;
  233. margin-right: 40rpx;
  234. }
  235. .case {
  236. position: absolute;
  237. left: 50%;
  238. transform: translateX(-50%);
  239. font-size: 36rpx;
  240. font-weight: 600;
  241. }
  242. }
  243. .content {
  244. padding: 0 24rpx;
  245. overflow-y: auto;
  246. flex: 1;
  247. .option {
  248. width: 100%;
  249. // height: 86rpx;
  250. padding: 20rpx 32rpx;
  251. background: #FFFFFF;
  252. box-shadow: 0px 2rpx 8rpx 0px rgba(214, 225, 237, 0.1);
  253. border-radius: 16rpx;
  254. margin-bottom: 16rpx;
  255. .name {
  256. width: 100%;
  257. display: flex;
  258. align-items: center;
  259. justify-content: space-between;
  260. margin-bottom: 16rpx;
  261. }
  262. .price {
  263. width: 100%;
  264. height: 78rpx;
  265. border-bottom: 1px solid #eeeeee;
  266. display: flex;
  267. align-items: start;
  268. justify-content: space-between;
  269. span {
  270. display: flex;
  271. align-items: center;
  272. }
  273. }
  274. .explain {
  275. margin-top: 16rpx;
  276. .text {
  277. width: 100%;
  278. height: 164rpx;
  279. background-color: #f7f8fc;
  280. margin-top: 12rpx;
  281. position: relative;
  282. span {
  283. position: absolute;
  284. bottom: 12rpx;
  285. right: 16rpx;
  286. font-size: 24rpx;
  287. color: #999999;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. .btn_box {
  294. width: 100%;
  295. height: 109rpx;
  296. background: #FFFFFF;
  297. display: flex;
  298. align-items: center;
  299. justify-content: space-around;
  300. margin-top: 10rpx;
  301. font-size: 28rpx;
  302. .customer {
  303. border-radius: 49rpx;
  304. border: 1px solid #2D88F4;
  305. width: 324rpx;
  306. height: 76rpx;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. color: #2D88F4;
  311. }
  312. .accept {
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. width: 324rpx;
  317. height: 76rpx;
  318. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  319. border-radius: 49rpx;
  320. color: #FFFFFF;
  321. }
  322. }
  323. }
  324. ::v-deep .custom-switch {
  325. width: 52rpx;
  326. /* 自定义宽度 */
  327. height: 27rpx;
  328. /* 自定义高度 */
  329. }
  330. ::v-deep .u-switch__node .node-class {
  331. width: 25rpx !important;
  332. /* 自定义按钮大小 */
  333. height: 25rpx !important;
  334. /* 自定义按钮大小 */
  335. }
  336. </style>