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.

550 lines
17 KiB

  1. <template>
  2. <!-- <view>打卡</view> -->
  3. <view class="box box-size">
  4. <view class="top box-size" :style="{borderRadius:'16rpx'}">
  5. <view class="form-title">
  6. 个人准备
  7. </view>
  8. <view class="mt32 ml10">
  9. <span :style="{fontSize:'30rpx',fontWeight:'400'}">手套照片</span>
  10. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(至少1张)</span>
  11. </view>
  12. <view class="level">
  13. <view class="mt20 ml10">
  14. <up-upload :fileList="fileList.glove" @afterRead="afterRead" @delete="deletePic" name="glove"
  15. multiple :maxCount="2" width="131rpx" height="131rpx" :disabled="isRead">
  16. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  17. </image>
  18. </up-upload>
  19. </view>
  20. </view>
  21. <view class="mt32 ml10">
  22. <span :style="{fontSize:'30rpx',fontWeight:'400'}">鞋套照片</span>
  23. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(至少1张)</span>
  24. </view>
  25. <view class="level">
  26. <view class="mt20 ml10">
  27. <up-upload :fileList="fileList.ShoeCover" @afterRead="afterRead" @delete="deletePic"
  28. name="ShoeCover" multiple :maxCount="2" width="131rpx" height="131rpx" :disabled="isRead">
  29. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  30. </image>
  31. </up-upload>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  36. <view class="form-title">
  37. 宠物状态记录
  38. </view>
  39. <view v-for="(pet, index) in petList" :key="index">
  40. <view class="mt32 ml10">
  41. <span :style="{fontSize:'30rpx',fontWeight:'400'}">{{ pet.title }}照片</span>
  42. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(至少2张)</span>
  43. </view>
  44. <view class="level">
  45. <view class="mt20 ml10 mr20">
  46. <up-upload :fileList="fileList['pet' + index]" @afterRead="afterRead" @delete="deletePic"
  47. :name="'pet' + index" multiple :maxCount="2" width="131rpx" height="131rpx" :disabled="isRead">
  48. <image src="/static/images/ydd/add_photo.png" mode=""
  49. :style="{width:'131rpx',height:'131rpx'}">
  50. </image>
  51. </up-upload>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  57. <view class="form-title">
  58. 基础服务记录
  59. </view>
  60. <view class="mt32 ml10" :style="{fontSize:'30rpx',fontWeight:'400'}">粮碗前后对比 </view>
  61. <view class="level">
  62. <view class="mt20 ml10">
  63. <up-upload :fileList="fileList.foodA" @afterRead="afterRead" @delete="deletePic" name="foodA"
  64. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  65. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  66. </image>
  67. </up-upload>
  68. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}">前</view>
  69. </view>
  70. <view class="mt20 ml10 ml28">
  71. <up-upload :fileList="fileList.foodB" @afterRead="afterRead" @delete="deletePic" name="foodB"
  72. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  73. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  74. </image>
  75. </up-upload>
  76. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}">后</view>
  77. </view>
  78. </view>
  79. <view class="mt32 ml10" :style="{fontSize:'30rpx',fontWeight:'400'}">水碗前后对比 </view>
  80. <view class="level">
  81. <view class="mt20 ml10">
  82. <up-upload :fileList="fileList.waterA" @afterRead="afterRead" @delete="deletePic" name="waterA"
  83. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  84. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  85. </image>
  86. </up-upload>
  87. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}">前</view>
  88. </view>
  89. <view class="mt20 ml10 ml28">
  90. <up-upload :fileList="fileList.waterB" @afterRead="afterRead" @delete="deletePic" name="waterB"
  91. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  92. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  93. </image>
  94. </up-upload>
  95. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}">后</view>
  96. </view>
  97. </view>
  98. <view class="mt32 ml10" :style="{fontSize:'30rpx',fontWeight:'400'}">猫砂盆、尿垫前后对比 </view>
  99. <view class="level">
  100. <view class="mt20 ml10">
  101. <up-upload :fileList="fileList.urinalA" @afterRead="afterRead" @delete="deletePic" name="urinalA"
  102. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  103. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  104. </image>
  105. </up-upload>
  106. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}">前</view>
  107. </view>
  108. <view class="mt20 ml10 ml28">
  109. <up-upload :fileList="fileList.urinalB" @afterRead="afterRead" @delete="deletePic" name="urinalB"
  110. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  111. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  112. </image>
  113. </up-upload>
  114. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}">后</view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  119. <view class="form-title">
  120. 定制服务记录
  121. </view>
  122. <view v-for="(product, pindex) in projectList"
  123. :key="pindex">
  124. <view class="mt32 ml10">
  125. <span :style="{fontSize:'30rpx',fontWeight:'400'}">{{ product.title }}</span>
  126. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(2-3张)</span>
  127. </view>
  128. <view class="level">
  129. <view class="mt20 ml10 mr20">
  130. <up-upload :fileList="fileList['project' + pindex]" @afterRead="afterRead" @delete="deletePic"
  131. :name="'project' + pindex"
  132. multiple :maxCount="3" width="131rpx" height="131rpx" :disabled="isRead">
  133. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  134. </image>
  135. </up-upload>
  136. </view>
  137. </view>
  138. </view>
  139. <!-- <view class="mt32 ml10">
  140. <span :style="{fontSize:'30rpx',fontWeight:'400'}">遛狗</span>
  141. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(2-3张)</span>
  142. </view>
  143. <view class="level">
  144. <view class="mt20 ml10 mr20">
  145. <up-upload :fileList="fileList.testa" @afterRead="afterRead" @delete="deletePic" name="testa"
  146. multiple :maxCount="3" width="131rpx" height="131rpx" :disabled="isRead">
  147. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  148. </image>
  149. </up-upload>
  150. </view>
  151. </view> -->
  152. <!-- <view class="mt32 ml10">
  153. <span :style="{fontSize:'30rpx',fontWeight:'400'}">陪玩</span>
  154. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(2-3张)</span>
  155. </view>
  156. <view class="level">
  157. <view class="mt20 ml10 mr20">
  158. <up-upload :fileList="fileList.testb" @afterRead="afterRead" @delete="deletePic" name="testb"
  159. multiple :maxCount="3" width="131rpx" height="131rpx" :disabled="isRead">
  160. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  161. </image>
  162. </up-upload>
  163. </view>
  164. </view> -->
  165. </view>
  166. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  167. <view class="form-title">
  168. 其他补充信息(必填)
  169. </view>
  170. <view class="mt32 ml10" :style="{color:'#999999',fontSize:'30rpx'}">
  171. 可记录一下今日趣事、宠物状况、提醒事项等,最少30个字
  172. </view>
  173. <view class="mt24">
  174. <textarea cols="30" rows="10"
  175. placeholder="请输入内容"
  176. v-model="form.notes"
  177. :style="{color:'#999999',fontSize:'30rpx',backgroundColor:'#F5F5F5',borderRadius:'16rpx',width:'681rpx',height:'180rpx'}"
  178. class="pd20 box-size" :disabled="isRead"></textarea>
  179. </view>
  180. </view>
  181. <view class="buttom mt60 box-size"
  182. v-if="!isRead"
  183. style="display: flex;gap: 20rpx;"
  184. >
  185. <view class="buttom-item buttom-item-2 level size-30"
  186. @click="saveDraft(false)"
  187. :style="{borderRadius:'41rpx',color:'#ff842c'}">
  188. 保存草稿
  189. </view>
  190. <view class="buttom-item level size-30"
  191. @click="submit"
  192. :style="{borderRadius:'41rpx',color:'#fff'}">
  193. 确定提交
  194. </view>
  195. </view>
  196. </view>
  197. </template>
  198. <script setup>
  199. import {
  200. onMounted,
  201. reactive,
  202. ref,
  203. } from "vue";
  204. import {
  205. onLoad
  206. } from '@dcloudio/uni-app'
  207. import {
  208. ossUpload
  209. } from '@/utils/oss-upload/oss/index.js'
  210. import {
  211. appletOrderDateFrequencyById,
  212. appletOrderDateFrequencyCheck,
  213. } from "@/api/order/frequency.js"
  214. onLoad((options) => {
  215. checkId.value = options.id || null;
  216. GetByOrderId()
  217. });
  218. const checkId = ref(0)
  219. const orderId = ref(0)
  220. const itemOrderID = ref(0)
  221. const serviceId = ref(0)
  222. const isRead = ref(false)
  223. const content = ref('')
  224. const fileList = reactive({
  225. // glove: [],//手套
  226. // ShoeCover: [],//鞋套
  227. // food: [],//粮碗
  228. // water: [],//水碗
  229. // urinal: [],//猫砂盆、尿盆
  230. })
  231. const form = ref({})
  232. const petList = ref([
  233. // {
  234. // title: '小汪'
  235. // },
  236. // {
  237. // title: '大黄'
  238. // },
  239. ])
  240. //附加项目
  241. const projectList = ref([
  242. // {
  243. // title: '小汪'
  244. // },
  245. // {
  246. // title: '大黄'
  247. // },
  248. ])
  249. // 删除图片
  250. const deletePic = (event) => {
  251. if (fileList[event.name]) {
  252. fileList[event.name].splice(event.index, 1);
  253. }
  254. };
  255. // 新增图片
  256. const afterRead = (event) => {
  257. if (!fileList[event.name]) {
  258. fileList[event.name] = []
  259. }
  260. event.file.forEach(n => {
  261. ossUpload(n.url)
  262. .then(url => {
  263. console.log(url);
  264. fileList[event.name].push({
  265. url
  266. })
  267. })
  268. })
  269. };
  270. function submit() {
  271. // 参数效验
  272. if (!fileList.glove || fileList.glove.length == 0) {
  273. return msg('请上传鞋套照片')
  274. }
  275. if (!fileList.ShoeCover || fileList.ShoeCover.length == 0) {
  276. return msg('请上传鞋套照片')
  277. }
  278. for (let i = 0; i < petList.value.length; i++) {
  279. if (!fileList['pet' + i] || fileList['pet' + i].length < 2) {
  280. return msg(`请上传${petList.value[i].title}照片`)
  281. }
  282. }
  283. if (!fileList.foodA || fileList.foodA.length < 1 ||
  284. !fileList.foodB || fileList.foodB.length < 1) {
  285. return msg('请上传粮碗前后照片')
  286. }
  287. if (!fileList.waterA || fileList.waterA.length < 1 ||
  288. !fileList.waterB || fileList.waterB.length < 1) {
  289. return msg('请上传水碗前后照片')
  290. }
  291. if (!fileList.urinalA || fileList.urinalA.length < 1 ||
  292. !fileList.urinalB || fileList.urinalB.length < 1) {
  293. return msg('请上传猫砂盆、尿盆照片')
  294. }
  295. for (let i = 0; i < projectList.value.length; i++) {
  296. if (!fileList['project' + i] || fileList['project' + i].length < 2) {
  297. return msg(`请上传${projectList.value[i].title}照片`)
  298. }
  299. }
  300. if(!form.value.notes){
  301. return msg('请填写补充信息')
  302. }
  303. if(form.value.notes.length < 30){
  304. return msg('补充信息不少于30字')
  305. }
  306. saveDraft(true)
  307. }
  308. function GetByOrderId(){
  309. appletOrderDateFrequencyById(checkId.value)
  310. .then(res => {
  311. const data = res.data.check;
  312. const frequency = res.data.frequency;
  313. isRead.value = frequency.status == 2
  314. if(res.code == 200 && data) {
  315. form.value = data
  316. // 回显手套照片
  317. if(data.glovePhoto) {
  318. fileList.glove = data.glovePhoto.split(',').map(url => ({ url }));
  319. }
  320. // 回显鞋套照片
  321. if(data.shoeCoverPhoto) {
  322. fileList.ShoeCover = data.shoeCoverPhoto.split(',').map(url => ({ url }));
  323. }
  324. // 回显宠物照片
  325. if(data.petPhoto) {
  326. const pets = JSON.parse(data.petPhoto);
  327. petList.value = pets;
  328. pets.forEach((pet, index) => {
  329. if(pet.fileList) {
  330. fileList['pet' + index] = pet.fileList.split(',').map(url => ({ url }));
  331. }
  332. });
  333. }
  334. // 回显项目照片
  335. if(data.workDogImage) {
  336. const pList = JSON.parse(data.workDogImage);
  337. projectList.value = pList;
  338. pList.forEach((pet, index) => {
  339. if(pet.fileList) {
  340. fileList['project' + index] = pet.fileList.split(',').map(url => ({ url }));
  341. }
  342. });
  343. }
  344. // 回显粮碗照片
  345. if(data.grainBowlFront) fileList.foodA = data.grainBowlFront.split(',').map(url => ({ url }));
  346. if(data.grainBowlAfter) fileList.foodB = data.grainBowlAfter.split(',').map(url => ({ url }));
  347. // 回显水碗照片
  348. if(data.waterBowlFront) fileList.waterA = data.waterBowlFront.split(',').map(url => ({ url }));
  349. if(data.waterBowlAfter) fileList.waterB = data.waterBowlAfter.split(',').map(url => ({ url }));
  350. // 回显猫砂盆/尿垫照片
  351. if(data.basinFront) fileList.urinalA = data.basinFront.split(',').map(url => ({ url }));
  352. if(data.basinAfter) fileList.urinalB = data.basinAfter.split(',').map(url => ({ url }));
  353. // 回显定制服务照片
  354. // if(data.workDogImage) fileList.testa = data.workDogImage.split(',').map(url => ({ url }));
  355. // if(data.workPalyImage) fileList.testb = data.workPalyImage.split(',').map(url => ({ url }));
  356. }else{
  357. // getOrderPetByIdFN()
  358. let projectNameList = []
  359. frequency.pets.forEach((n, i) => {
  360. fileList['pet' + i] = []
  361. n.orderItemList.forEach((item, inde) => {
  362. fileList['project' + inde] = []
  363. })
  364. })
  365. frequency.pets.forEach((n, i) => {
  366. petList.value.push({
  367. title : n.name,
  368. id : n.id,
  369. })
  370. n.orderItemList.forEach((item, inde) => {
  371. if(!projectNameList.includes(item.productName)){
  372. projectNameList.push(item.productName)
  373. projectList.value.push({
  374. title : item.productName,
  375. ids : [item.id]
  376. })
  377. }else{
  378. projectList.value[projectNameList.indexOf(item.productName)].ids.push(item.id)
  379. }
  380. })
  381. })
  382. }
  383. })
  384. }
  385. function getOrderPetByIdFN(){
  386. getOrderPetById(orderId.value)
  387. .then(res => {
  388. if(res.code == 200){
  389. res.data.forEach((n, i) => {
  390. fileList['pet' + i] = []
  391. })
  392. res.data.forEach((n, i) => {
  393. petList.value.push({
  394. title : n.name,
  395. id : n.id,
  396. })
  397. })
  398. }
  399. })
  400. }
  401. function saveDraft(flag) {
  402. // 将所有图片数组转换为逗号分隔的字符串
  403. const params = {
  404. // orderId: orderId.value,
  405. // itemOrderId : itemOrderID.value,
  406. itemDateId : checkId.value,
  407. glovePhoto: fileList.glove?.map(item => item.url).join(',') || '',
  408. shoeCoverPhoto: fileList.ShoeCover?.map(item => item.url).join(',') || '',
  409. // 合并所有宠物照片
  410. petPhoto: JSON.stringify(
  411. petList.value.map((pet, index) => {
  412. return {
  413. id : pet.id,
  414. title : pet.title,
  415. fileList: fileList['pet' + index]?.map(item => item.url).join(',') || ''
  416. };
  417. })
  418. ),
  419. workDogImage: JSON.stringify(
  420. projectList.value.map((pet, index) => {
  421. return {
  422. id : pet.id,
  423. title : pet.title,
  424. fileList: fileList['project' + index]?.map(item => item.url).join(',') || ''
  425. };
  426. })
  427. ),
  428. // 粮碗照片
  429. grainBowlFront: fileList.foodA?.map(item => item.url).join(',') || '',
  430. grainBowlAfter: fileList.foodB?.map(item => item.url).join(',') || '',
  431. // 水碗照片
  432. waterBowlFront: fileList.waterA?.map(item => item.url).join(',') || '',
  433. waterBowlAfter: fileList.waterB?.map(item => item.url).join(',') || '',
  434. // 猫砂盆/尿垫照片
  435. basinFront: fileList.urinalA?.map(item => item.url).join(',') || '',
  436. basinAfter: fileList.urinalB?.map(item => item.url).join(',') || '',
  437. // 定制服务照片
  438. // workDogImage: fileList.testa?.map(item => item.url).join(',') || '',
  439. // workPalyImage: fileList.testb?.map(item => item.url).join(',') || '',
  440. // 备注信息
  441. notes: form.value.notes || '',
  442. submitFlag : 1,//草稿
  443. }
  444. if(form.value.id) {
  445. params.id = form.value.id
  446. }
  447. if(flag) {
  448. params.submitFlag = 2
  449. }
  450. appletOrderDateFrequencyCheck(params)
  451. .then(res => {
  452. if(res.code === 200) {
  453. uni.showToast({
  454. title: '提交成功',
  455. icon: 'success'
  456. })
  457. // 如果是确认提交(非草稿),则返回上一页
  458. setTimeout(() => {
  459. uni.navigateBack()
  460. }, 1500)
  461. } else {
  462. uni.showToast({
  463. title: res.msg || '提交失败',
  464. icon: 'none'
  465. })
  466. }
  467. })
  468. .catch(err => {
  469. uni.showToast({
  470. title: '提交失败',
  471. icon: 'none'
  472. })
  473. })
  474. }
  475. function msg(content) {
  476. uni.showToast({
  477. title: content,
  478. icon: 'none'
  479. })
  480. }
  481. </script>
  482. <style scoped lang="scss">
  483. @import"index.scss"
  484. </style>