展品维保小程序前端代码接口
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.

687 lines
18 KiB

1 week ago
6 days ago
6 days ago
6 days ago
1 week ago
1 week ago
1 week ago
  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 || '请选择' }}</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. this.malfunctionDate = this.$utils.formatTime(e.value)
  301. },
  302. // 显示紧急程度选择器
  303. showUrgencyPicker() {
  304. this.$refs.urgencyPicker.open()
  305. },
  306. // 确认紧急程度
  307. confirmUrgency(e) {
  308. this.urgency = e.value[0]
  309. },
  310. // 取消紧急程度选择
  311. cancelUrgency() {
  312. // 取消操作
  313. },
  314. // 显示故障情况选择器
  315. showFaultPicker() {
  316. this.$refs.faultPicker.open()
  317. },
  318. // 确认故障情况
  319. confirmFault(e) {
  320. this.malfunctionStatus = e.value[0]
  321. },
  322. // 取消故障情况选择
  323. cancelFault() {
  324. // 取消操作
  325. },
  326. // 显示故障首次发生时间选择器
  327. showFirstOccurTimePicker() {
  328. this.$refs.firstOccurTimePicker.open()
  329. },
  330. // 确认故障首次发生时间
  331. confirmFirstOccurTime(e) {
  332. this.firstDate = this.$utils.formatTime(e.value)
  333. },
  334. // 显示影响使用选择器
  335. showImpactPicker() {
  336. this.$refs.impactPicker.open()
  337. },
  338. // 确认影响使用
  339. confirmImpact(e) {
  340. this.isAffectUse = e.value[0]
  341. },
  342. // 取消影响使用选择
  343. cancelImpact() {
  344. // 取消操作
  345. },
  346. // 选择频率
  347. selectFrequency(value) {
  348. this.frequency = value
  349. },
  350. // 选择是否采取措施
  351. selectMeasures(value) {
  352. this.isMeasure = value
  353. },
  354. // 选择是否影响体验
  355. selectExperience(value) {
  356. this.isAffectExperience = value
  357. },
  358. // 上传图片
  359. async uploadImage() {
  360. try {
  361. const result = await this.$utils.chooseAndUpload()
  362. if (result && result.success) {
  363. console.log(result);
  364. this.malfunctionImage.push(result.url)
  365. }
  366. } catch (error) {
  367. console.error('头像上传失败:', error)
  368. uni.showToast({
  369. title: '头像上传失败',
  370. icon: 'error'
  371. })
  372. }
  373. },
  374. // 删除图片
  375. deleteImage(index) {
  376. this.malfunctionImage.splice(index, 1)
  377. },
  378. // 预览图片
  379. previewImage(url) {
  380. uni.previewImage({
  381. urls: this.malfunctionImage,
  382. current: url
  383. })
  384. },
  385. // 提交报修
  386. async submitRepair() {
  387. // 表单验证
  388. if (!this.urgency) {
  389. uni.showToast({ title: '请选择故障紧急程度', icon: 'none' })
  390. return
  391. }
  392. if (!this.malfunctionImage.length) {
  393. uni.showToast({ title: '请上传故障图片', icon: 'none' })
  394. return
  395. }
  396. if (!this.malfunctionDesc.trim()) {
  397. uni.showToast({ title: '请填写故障情况描述', icon: 'none' })
  398. return
  399. }
  400. if (!this.firstDate.trim()) {
  401. uni.showToast({ title: '请选择故障首次发生时间', icon: 'none' })
  402. return
  403. }
  404. // 提交数据
  405. const formData = {
  406. showpieceId: this.showpieceId,
  407. malfunctionDate: this.malfunctionDate,
  408. urgency: this.urgency.value,
  409. malfunctionDesc: this.malfunctionStatus + this.malfunctionDesc,
  410. malfunctionImage: this.malfunctionImage.join(','),
  411. firstDate: this.firstDate,
  412. frequency: this.frequency,
  413. reason: this.reason,
  414. isAffectUse: this.isAffectUse.value,
  415. malfunctionName: this.malfunctionName,
  416. isMeasure: this.isMeasure,
  417. isAffectExperience: this.isAffectExperience,
  418. remark: this.remark
  419. }
  420. // console.log('提交数据:', formData)
  421. // uni.showToast({ title: '提交成功', icon: 'success' })
  422. const subRes = await this.$api.exhibit.addMalfunction({...formData})
  423. if (subRes.code === 200) {
  424. uni.showToast({ title: subRes.message})
  425. setTimeout(() => {
  426. uni.navigateBack()
  427. }, 1000)
  428. }else{
  429. uni.showToast({ title: subRes.message, icon: 'none' })
  430. }
  431. }
  432. },
  433. async onLoad(args) {
  434. this.showpieceId = args.id
  435. try {
  436. const listRes = await this.$api.config.queryMalfunctionDescList()
  437. if (listRes.code === 200) {
  438. this.faultColumns = [[...listRes.result.records.map(item => item.malfunction)]]
  439. }
  440. } catch (error) {
  441. uni.showToast({ title: error.message, icon: 'none' })
  442. }
  443. }
  444. }
  445. </script>
  446. <style lang="scss" scoped>
  447. .repair-submit {
  448. min-height: 100vh;
  449. background-color: #f5f5f5;
  450. padding-bottom: 200rpx;
  451. }
  452. .repair-info {
  453. margin: 18rpx;
  454. background: #ffffff;
  455. border-radius: 15rpx;
  456. box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  457. padding: 40rpx;
  458. .info-header {
  459. display: flex;
  460. align-items: center;
  461. margin-bottom: 40rpx;
  462. .red-line {
  463. width: 9rpx;
  464. height: 33rpx;
  465. background-color: $primary-color;
  466. margin-right: 7rpx;
  467. border-radius: 5rpx;
  468. }
  469. .info-title {
  470. font-size: 30rpx;
  471. font-weight: bold;
  472. color: $primary-text-color;
  473. }
  474. }
  475. .form-item-header {
  476. border-bottom: none;
  477. margin-top: 20rpx;
  478. }
  479. .form-item {
  480. display: flex;
  481. align-items: center;
  482. justify-content: space-between;
  483. padding: 24rpx 0;
  484. border-bottom: 2rpx solid #f0f0f0;
  485. &:last-child {
  486. border-bottom: none;
  487. }
  488. .label {
  489. font-size: 30rpx;
  490. color: $primary-text-color;
  491. flex-shrink: 0;
  492. &.active {
  493. font-weight: bold;
  494. }
  495. }
  496. .value {
  497. font-size: 30rpx;
  498. color: $secondary-text-color;
  499. &.placeholder {
  500. color: $secondary-text-color;
  501. }
  502. }
  503. .select-area {
  504. display: flex;
  505. align-items: center;
  506. gap: 16rpx;
  507. }
  508. }
  509. .textarea-container {
  510. // margin: 16rpx 0 32rpx 0;
  511. // background-color: #f5f5f5;
  512. border-radius: 8rpx;
  513. // padding: 16rpx;
  514. }
  515. .image-upload {
  516. display: flex;
  517. flex-wrap: wrap;
  518. gap: 24rpx;
  519. margin: 16rpx 0;
  520. .upload-btn {
  521. width: 160rpx;
  522. height: 160rpx;
  523. border: 2rpx dashed $primary-color;
  524. // border-radius: 8rpx;
  525. display: flex;
  526. align-items: center;
  527. justify-content: center;
  528. background-color: #fff;
  529. }
  530. .image-item {
  531. position: relative;
  532. width: 160rpx;
  533. height: 160rpx;
  534. image {
  535. width: 100%;
  536. height: 100%;
  537. border-radius: 8rpx;
  538. }
  539. .delete-btn {
  540. position: absolute;
  541. top: -12rpx;
  542. right: -12rpx;
  543. width: 40rpx;
  544. height: 40rpx;
  545. background-color: #ff4757;
  546. border-radius: 50%;
  547. display: flex;
  548. align-items: center;
  549. justify-content: center;
  550. }
  551. }
  552. }
  553. .hint-text {
  554. font-size: 24rpx;
  555. color: #999;
  556. margin-top: 16rpx;
  557. }
  558. .form-item .radio-options {
  559. display: flex;
  560. gap: 60rpx;
  561. .radio-item {
  562. display: flex;
  563. align-items: center;
  564. gap: 16rpx;
  565. .radio-dot {
  566. width: 32rpx;
  567. height: 32rpx;
  568. border: 4rpx solid #ddd;
  569. border-radius: 50%;
  570. position: relative;
  571. &.active {
  572. border-color: $primary-color;
  573. color: $primary-color;
  574. &::after {
  575. content: '';
  576. position: absolute;
  577. top: 50%;
  578. left: 50%;
  579. transform: translate(-50%, -50%);
  580. width: 16rpx;
  581. height: 16rpx;
  582. background-color: $primary-color;
  583. border-radius: 50%;
  584. }
  585. }
  586. }
  587. text {
  588. font-size: 30rpx;
  589. color: $secondary-text-color;
  590. &.active {
  591. color: $primary-color;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. .submit-container {
  598. position: fixed;
  599. bottom: 0;
  600. left: 0;
  601. right: 0;
  602. padding: 32rpx;
  603. background-color: #fff;
  604. border-top: 2rpx solid #f0f0f0;
  605. }
  606. </style>