展品维保小程序前端代码接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

679 lines
18 KiB

  1. <template>
  2. <view class="repair-submit">
  3. <!-- 导航栏 -->
  4. <!-- <uv-navbar title="报修提交" :border="false" bg-color="#ffffff" title-color="#333333" /> -->
  5. <!-- 报修基本信息 -->
  6. <view class="repair-info">
  7. <view class="info-header">
  8. <view class="red-line"></view>
  9. <text class="info-title">报修基本信息</text>
  10. </view>
  11. <!-- 报修日期 -->
  12. <view class="form-item" @click="showDatePicker">
  13. <text class="label">报修日期</text>
  14. <view class="select-area">
  15. <text class="value" :class="{ placeholder: !malfunctionDate }">{{ malfunctionDate || '请选择' }}</text>
  16. <uv-icon name="arrow-down" size="18" color="#000"></uv-icon>
  17. </view>
  18. </view>
  19. <!-- 故障紧急程度 -->
  20. <view class="form-item " @click="showUrgencyPicker">
  21. <text class="label">故障紧急程度</text>
  22. <view class="select-area">
  23. <text class="value" :class="{ placeholder: !urgency }">{{ urgency.label || '请选择' }}</text>
  24. <uv-icon name="arrow-down" size="18" color="#000"></uv-icon>
  25. </view>
  26. </view>
  27. <!-- 故障情况 -->
  28. <view class="form-item form-item-header">
  29. <text class="label active">故障情况</text>
  30. </view>
  31. <!-- 故障情况选择 -->
  32. <view class="form-item" @click="showFaultPicker">
  33. <text class="label">故障情况</text>
  34. <view class="select-area">
  35. <text class="value" :class="{ placeholder: !malfunctionStatus }">{{ malfunctionStatus.label || '请选择' }}</text>
  36. <uv-icon name="arrow-down" size="18" color="#000"></uv-icon>
  37. </view>
  38. </view>
  39. <!-- 故障情况描述 -->
  40. <view class="form-item">
  41. <text class="label">故障情况描述</text>
  42. </view>
  43. <view class="textarea-container">
  44. <uv-textarea
  45. v-model="malfunctionDesc"
  46. placeholder="请对故障情况进行描述"
  47. :maxlength="200"
  48. :show-confirm-bar="false"
  49. height="60"
  50. border="none"
  51. :custom-style="{ backgroundColor: '#f5f5f5' }"
  52. ></uv-textarea>
  53. </view>
  54. <!-- 故障图片 -->
  55. <view class="form-item">
  56. <text class="label">故障图片</text>
  57. </view>
  58. <view class="image-upload">
  59. <view v-for="(img, index) in malfunctionImage" :key="index" class="image-item">
  60. <image :src="img" mode="aspectFill" @click="previewImage(img)"></image>
  61. <view class="delete-btn" @click="deleteImage(index)">
  62. <uv-icon name="close" size="12" color="#fff"></uv-icon>
  63. </view>
  64. </view>
  65. <view class="upload-btn" @click="uploadImage">
  66. <uv-icon name="camera" size="34" color="#C70019"></uv-icon>
  67. </view>
  68. </view>
  69. <!-- 故障首次发生时间 -->
  70. <view class="form-item" @click="showFirstOccurTimePicker">
  71. <text class="label">故障首次发生时间</text>
  72. <view class="select-area">
  73. <text class="value" :class="{ placeholder: !firstDate }">{{ firstDate || '请选择' }}</text>
  74. <uv-icon name="arrow-down" size="18" color="#000"></uv-icon>
  75. </view>
  76. </view>
  77. <!-- 发生频率 -->
  78. <view class="form-item">
  79. <text class="label">发生频率</text>
  80. <view class="radio-options">
  81. <view
  82. v-for="(item, index) in frequencyOptions"
  83. :key="index"
  84. class="radio-item"
  85. :class="{ active: frequency === item.value }"
  86. @click="selectFrequency(item.value)"
  87. >
  88. <view class="radio-dot" :class="{ active: frequency === item.value }"></view>
  89. <text :class="{ active: frequency === item.value }">{{ item.label }}</text>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 请描述与故障设备发生主要故障的具体条件 -->
  94. <!-- <view class="form-item">
  95. <text class="label">请描述与故障设备发生主要故障的具体条件</text>
  96. </view> -->
  97. <view class="textarea-container">
  98. <uv-textarea
  99. v-model="reason"
  100. placeholder="请填写说明故障发生频率的触发条件"
  101. :maxlength="200"
  102. :show-confirm-bar="false"
  103. height="60"
  104. border="none"
  105. :custom-style="{ backgroundColor: '#f5f5f5' }"
  106. ></uv-textarea>
  107. </view>
  108. <!-- 是否影响使用 -->
  109. <view class="form-item" @click="showImpactPicker">
  110. <text class="label">是否影响使用</text>
  111. <view class="select-area">
  112. <text class="value" :class="{ placeholder: !isAffectUse }">{{ isAffectUse.label || '请选择' }}</text>
  113. <uv-icon name="arrow-down" size="18" color="#000"></uv-icon>
  114. </view>
  115. </view>
  116. <!-- 采取的临时措施 -->
  117. <!-- 故障情况 -->
  118. <view class="form-item form-item-header">
  119. <text class="label active">采取的临时措施</text>
  120. </view>
  121. <!-- <view class="form-item">
  122. <text class="label">是否采取临时措施</text>
  123. </view>
  124. <view class="textarea-container">
  125. <uv-textarea
  126. v-model="malfunctionName"
  127. placeholder="如有采取临时措施请填写措施说明"
  128. :maxlength="200"
  129. :show-confirm-bar="false"
  130. height="60"
  131. border="none"
  132. :custom-style="{ backgroundColor: '#f5f5f5' }"
  133. ></uv-textarea>
  134. </view> -->
  135. <!-- 是否采取的对措施 -->
  136. <view class="form-item">
  137. <text class="label">是否采取的对措施</text>
  138. <view class="radio-options">
  139. <view
  140. class="radio-item"
  141. :class="{ active: isMeasure === '1' }"
  142. @click="selectMeasures('1')"
  143. >
  144. <view class="radio-dot" :class="{ active: isMeasure === '1' }"></view>
  145. <text :class="{ active: isMeasure === '1' }"></text>
  146. </view>
  147. <view
  148. class="radio-item"
  149. :class="{ active: isMeasure === '0' }"
  150. @click="selectMeasures('0')"
  151. >
  152. <view class="radio-dot" :class="{ active: isMeasure === '0' }"></view>
  153. <text :class="{ active: isMeasure === '0' }"></text>
  154. </view>
  155. </view>
  156. </view>
  157. <view class="textarea-container">
  158. <uv-textarea
  159. v-model="malfunctionName"
  160. placeholder="如有采取临时措施请填写措施说明"
  161. :maxlength="200"
  162. :show-confirm-bar="false"
  163. height="60"
  164. border="none"
  165. :custom-style="{ backgroundColor: '#f5f5f5' }"
  166. ></uv-textarea>
  167. </view>
  168. <!-- 是否影响体验 -->
  169. <view class="form-item">
  170. <text class="label">是否影响体验</text>
  171. <view class="radio-options">
  172. <view
  173. class="radio-item"
  174. :class="{ active: isAffectExperience === '1' }"
  175. @click="selectExperience('1')"
  176. >
  177. <view class="radio-dot" :class="{ active: isAffectExperience === '1' }"></view>
  178. <text :class="{ active: isAffectExperience === '1' }"></text>
  179. </view>
  180. <view
  181. class="radio-item"
  182. :class="{ active: isAffectExperience === '0' }"
  183. @click="selectExperience('0')"
  184. >
  185. <view class="radio-dot" :class="{ active: isAffectExperience === '0' }"></view>
  186. <text :class="{ active: isAffectExperience === '0' }"></text>
  187. </view>
  188. </view>
  189. </view>
  190. <!-- 备注 -->
  191. <view class="form-item">
  192. <text class="label">备注</text>
  193. </view>
  194. <view class="textarea-container">
  195. <uv-textarea
  196. v-model="remark"
  197. placeholder="备注"
  198. :maxlength="200"
  199. :show-confirm-bar="false"
  200. height="60"
  201. border="none"
  202. :custom-style="{ backgroundColor: '#f5f5f5' }"
  203. ></uv-textarea>
  204. </view>
  205. </view>
  206. <!-- 提交按钮 -->
  207. <view class="submit-container">
  208. <uv-button
  209. type="primary"
  210. text="立即提交"
  211. :custom-style="{ backgroundColor: '#C70019', borderRadius: '25px' }"
  212. @click="submitRepair"
  213. ></uv-button>
  214. </view>
  215. <!-- 选择器 -->
  216. <uv-picker
  217. confirm-color="#C70019"
  218. ref="urgencyPicker"
  219. :columns="urgencyColumns"
  220. keyName="label"
  221. @confirm="confirmUrgency"
  222. @cancel="cancelUrgency"
  223. ></uv-picker>
  224. <uv-picker
  225. confirm-color="#C70019"
  226. ref="faultPicker"
  227. :columns="faultColumns"
  228. @confirm="confirmFault"
  229. @cancel="cancelFault"
  230. ></uv-picker>
  231. <!-- 故障首次发生时间选择器 -->
  232. <uv-datetime-picker
  233. ref="firstOccurTimePicker"
  234. mode="date"
  235. confirm-color="#C70019"
  236. @confirm="confirmFirstOccurTime"
  237. ></uv-datetime-picker>
  238. <uv-picker
  239. confirm-color="#C70019"
  240. ref="impactPicker"
  241. :columns="impactColumns"
  242. @confirm="confirmImpact"
  243. @cancel="cancelImpact"
  244. keyName="label"
  245. ></uv-picker>
  246. <!-- 日期选择器 -->
  247. <uv-datetime-picker
  248. confirm-color="#C70019"
  249. ref="datePicker"
  250. mode="date"
  251. @confirm="confirmDate"
  252. ></uv-datetime-picker>
  253. </view>
  254. </template>
  255. <script>
  256. export default {
  257. data() {
  258. return {
  259. // 表单数据
  260. malfunctionDate: '',
  261. urgency: '',
  262. malfunctionStatus: '',
  263. malfunctionDesc: '',
  264. malfunctionImage: [],
  265. firstDate: '',
  266. frequency: '1',
  267. reason: '',
  268. isAffectUse: '0',
  269. malfunctionName: '',
  270. isMeasure: '0',
  271. isAffectExperience: '0',
  272. remark: '',
  273. showpieceId: '',
  274. // 频率选项
  275. frequencyOptions: [
  276. { label: '持续性问题', value: '0' },
  277. { label: '间歇性问题', value: '1' }
  278. ],
  279. // 选择器数据
  280. urgencyColumns: [
  281. [
  282. { label: '一般', value: '0' },
  283. { label: '紧急', value: '1'}
  284. ]
  285. ],
  286. faultColumns: [['硬件故障', '软件故障', '网络故障', '其他']],
  287. impactColumns: [[
  288. { label: '是', value: '1' },
  289. { label: '否', value: '0' }
  290. ]],
  291. }
  292. },
  293. methods: {
  294. // 显示日期选择器
  295. showDatePicker() {
  296. this.$refs.datePicker.open()
  297. },
  298. // 确认日期选择
  299. confirmDate(e) {
  300. const date = new Date(e.value)
  301. this.malfunctionDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
  302. },
  303. // 显示紧急程度选择器
  304. showUrgencyPicker() {
  305. this.$refs.urgencyPicker.open()
  306. },
  307. // 确认紧急程度
  308. confirmUrgency(e) {
  309. this.urgency = e.value[0]
  310. },
  311. // 取消紧急程度选择
  312. cancelUrgency() {
  313. // 取消操作
  314. },
  315. // 显示故障情况选择器
  316. showFaultPicker() {
  317. this.$refs.faultPicker.open()
  318. },
  319. // 确认故障情况
  320. confirmFault(e) {
  321. this.malfunctionStatus = e.value[0]
  322. },
  323. // 取消故障情况选择
  324. cancelFault() {
  325. // 取消操作
  326. },
  327. // 显示故障首次发生时间选择器
  328. showFirstOccurTimePicker() {
  329. this.$refs.firstOccurTimePicker.open()
  330. },
  331. // 确认故障首次发生时间
  332. confirmFirstOccurTime(e) {
  333. const date = new Date(e.value)
  334. this.firstDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
  335. },
  336. // 显示影响使用选择器
  337. showImpactPicker() {
  338. this.$refs.impactPicker.open()
  339. },
  340. // 确认影响使用
  341. confirmImpact(e) {
  342. this.isAffectUse = e.value[0]
  343. },
  344. // 取消影响使用选择
  345. cancelImpact() {
  346. // 取消操作
  347. },
  348. // 选择频率
  349. selectFrequency(value) {
  350. this.frequency = value
  351. },
  352. // 选择是否采取措施
  353. selectMeasures(value) {
  354. this.isMeasure = value
  355. },
  356. // 选择是否影响体验
  357. selectExperience(value) {
  358. this.isAffectExperience = value
  359. },
  360. // 上传图片
  361. async uploadImage() {
  362. try {
  363. const result = await this.$utils.chooseAndUpload()
  364. if (result && result.success) {
  365. console.log(result);
  366. this.malfunctionImage.push(result.url)
  367. }
  368. } catch (error) {
  369. console.error('头像上传失败:', error)
  370. uni.showToast({
  371. title: '头像上传失败',
  372. icon: 'error'
  373. })
  374. }
  375. },
  376. // 删除图片
  377. deleteImage(index) {
  378. this.malfunctionImage.splice(index, 1)
  379. },
  380. // 预览图片
  381. previewImage(url) {
  382. uni.previewImage({
  383. urls: this.malfunctionImage,
  384. current: url
  385. })
  386. },
  387. // 提交报修
  388. async submitRepair() {
  389. // 表单验证
  390. if (!this.urgency) {
  391. uni.showToast({ title: '请选择故障紧急程度', icon: 'none' })
  392. return
  393. }
  394. // if (!this.malfunctionStatus) {
  395. // uni.showToast({ title: '请选择故障情况', icon: 'none' })
  396. // return
  397. // }
  398. if (!this.malfunctionDesc.trim()) {
  399. uni.showToast({ title: '请填写故障情况描述', icon: 'none' })
  400. return
  401. }
  402. // 提交数据
  403. const formData = {
  404. showpieceId: this.showpieceId,
  405. malfunctionDate: this.malfunctionDate,
  406. urgency: this.urgency.value,
  407. malfunctionStatus: this.malfunctionStatus.id,
  408. malfunctionDesc: this.malfunctionDesc,
  409. malfunctionImage: this.malfunctionImage.join(','),
  410. firstDate: this.firstDate,
  411. frequency: this.frequency,
  412. reason: this.reason,
  413. isAffectUse: this.isAffectUse.value,
  414. malfunctionName: this.malfunctionName,
  415. isMeasure: this.isMeasure,
  416. isAffectExperience: this.isAffectExperience,
  417. remark: this.remark
  418. }
  419. // console.log('提交数据:', formData)
  420. // uni.showToast({ title: '提交成功', icon: 'success' })
  421. const subRes = await this.$api.exhibit.addMalfunction(formData)
  422. if (subRes.code === 200) {
  423. uni.showToast({ title: subRes.message})
  424. setTimeout(() => {
  425. uni.navigateBack()
  426. }, 1000)
  427. }else{
  428. uni.showToast({ title: subRes.message, icon: 'none' })
  429. }
  430. }
  431. },
  432. onLoad(args) {
  433. this.showpieceId = args.id
  434. }
  435. }
  436. </script>
  437. <style lang="scss" scoped>
  438. .repair-submit {
  439. min-height: 100vh;
  440. background-color: #f5f5f5;
  441. padding-bottom: 200rpx;
  442. }
  443. .repair-info {
  444. margin: 18rpx;
  445. background: #ffffff;
  446. border-radius: 15rpx;
  447. box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  448. padding: 40rpx;
  449. .info-header {
  450. display: flex;
  451. align-items: center;
  452. margin-bottom: 40rpx;
  453. .red-line {
  454. width: 9rpx;
  455. height: 33rpx;
  456. background-color: $primary-color;
  457. margin-right: 7rpx;
  458. border-radius: 5rpx;
  459. }
  460. .info-title {
  461. font-size: 30rpx;
  462. font-weight: bold;
  463. color: $primary-text-color;
  464. }
  465. }
  466. .form-item-header {
  467. border-bottom: none;
  468. margin-top: 20rpx;
  469. }
  470. .form-item {
  471. display: flex;
  472. align-items: center;
  473. justify-content: space-between;
  474. padding: 24rpx 0;
  475. border-bottom: 2rpx solid #f0f0f0;
  476. &:last-child {
  477. border-bottom: none;
  478. }
  479. .label {
  480. font-size: 30rpx;
  481. color: $primary-text-color;
  482. flex-shrink: 0;
  483. &.active {
  484. font-weight: bold;
  485. }
  486. }
  487. .value {
  488. font-size: 30rpx;
  489. color: $secondary-text-color;
  490. &.placeholder {
  491. color: $secondary-text-color;
  492. }
  493. }
  494. .select-area {
  495. display: flex;
  496. align-items: center;
  497. gap: 16rpx;
  498. }
  499. }
  500. .textarea-container {
  501. // margin: 16rpx 0 32rpx 0;
  502. // background-color: #f5f5f5;
  503. border-radius: 8rpx;
  504. // padding: 16rpx;
  505. }
  506. .image-upload {
  507. display: flex;
  508. flex-wrap: wrap;
  509. gap: 24rpx;
  510. margin: 16rpx 0;
  511. .upload-btn {
  512. width: 160rpx;
  513. height: 160rpx;
  514. border: 2rpx dashed $primary-color;
  515. // border-radius: 8rpx;
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. background-color: #fff;
  520. }
  521. .image-item {
  522. position: relative;
  523. width: 160rpx;
  524. height: 160rpx;
  525. image {
  526. width: 100%;
  527. height: 100%;
  528. border-radius: 8rpx;
  529. }
  530. .delete-btn {
  531. position: absolute;
  532. top: -12rpx;
  533. right: -12rpx;
  534. width: 40rpx;
  535. height: 40rpx;
  536. background-color: #ff4757;
  537. border-radius: 50%;
  538. display: flex;
  539. align-items: center;
  540. justify-content: center;
  541. }
  542. }
  543. }
  544. .hint-text {
  545. font-size: 24rpx;
  546. color: #999;
  547. margin-top: 16rpx;
  548. }
  549. .form-item .radio-options {
  550. display: flex;
  551. gap: 60rpx;
  552. .radio-item {
  553. display: flex;
  554. align-items: center;
  555. gap: 16rpx;
  556. .radio-dot {
  557. width: 32rpx;
  558. height: 32rpx;
  559. border: 4rpx solid #ddd;
  560. border-radius: 50%;
  561. position: relative;
  562. &.active {
  563. border-color: $primary-color;
  564. color: $primary-color;
  565. &::after {
  566. content: '';
  567. position: absolute;
  568. top: 50%;
  569. left: 50%;
  570. transform: translate(-50%, -50%);
  571. width: 16rpx;
  572. height: 16rpx;
  573. background-color: $primary-color;
  574. border-radius: 50%;
  575. }
  576. }
  577. }
  578. text {
  579. font-size: 30rpx;
  580. color: $secondary-text-color;
  581. &.active {
  582. color: $primary-color;
  583. }
  584. }
  585. }
  586. }
  587. }
  588. .submit-container {
  589. position: fixed;
  590. bottom: 0;
  591. left: 0;
  592. right: 0;
  593. padding: 32rpx;
  594. background-color: #fff;
  595. border-top: 2rpx solid #f0f0f0;
  596. }
  597. </style>