CfAppraise.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="cf-appraise">
  3. <pub-loading-view :loaded="loaded" height="100%">
  4. <view class="cf-appraise-section" v-if="info">
  5. <view class="cf-appraise-top-section">
  6. <view class="cf-appraise-top">
  7. <view class="cf-appraise-top-title">“中医用药一件事”满意度调查</view>
  8. <view class="cf-appraise-top-comprehensive">
  9. <view class="appraise-star-title">综合评价</view>
  10. <view class="cf-appraise-top-comprehensive-item" :class="info.comprehensiveVal==1?'is-active':''"
  11. @click="onClickComprehensive(1)">
  12. <text class="iconfont">&#xe687;</text>差评
  13. </view>
  14. <view class="cf-appraise-top-comprehensive-item" :class="info.comprehensiveVal==2?'is-active':''"
  15. @click="onClickComprehensive(2)">
  16. <text class="iconfont">&#xe698;</text>中评
  17. </view>
  18. <view class="cf-appraise-top-comprehensive-item" :class="info.comprehensiveVal==3?'is-active':''"
  19. @click="onClickComprehensive(3)">
  20. <text class="iconfont">&#xe696;</text>好评
  21. </view>
  22. </view>
  23. <CfAppraiseStar :isEdit="isEdit" title="就医效果" :starText="starText[0]" v-model:starval="info.starVal[0]" />
  24. <CfAppraiseStar :isEdit="isEdit" title="开方医生" :starText="starText[1]" v-model:starval="info.starVal[1]" />
  25. <CfAppraiseStar :isEdit="isEdit" title="煎药质量" :starText="starText[2]" v-model:starval="info.starVal[2]" />
  26. <CfAppraiseStar :isEdit="isEdit" title="物流服务" :starText="starText[3]" v-model:starval="info.starVal[3]" />
  27. </view>
  28. <view class="cf-appraise-view" v-if="isEdit">
  29. <view class="cf-appraise-view-text">{{info.text}}</view>
  30. <view class="cf-appraise-view-imgs">
  31. <image mode="heightFix" :src="item" v-for="(item,index) in info.imgList" :key="index" />
  32. </view>
  33. </view>
  34. <view class="cf-appraise-edit" v-else>
  35. <view class="cf-appraise-edit-textarea">
  36. <textarea v-model="info.text" class="textarea" :disabled="false" placeholder-style="color:#B3B5B9"
  37. maxlength="-1" placeholder="展开说说您对“中医用药一件事”的想法吧..." />
  38. </view>
  39. <!-- 最多三张 -->
  40. <view class="picture-item" v-if="true">
  41. <uni-file-picker class="file-picker" limit="3" :auto-upload="false" :del-icon="true"
  42. file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image" v-model="fileList" @select="onSelectFile"
  43. @delete="onDelFile">
  44. <view class="cf-appraise-edit-add">
  45. <text class="iconfont">&#xe69f;</text>
  46. </view>
  47. </uni-file-picker>
  48. </view>
  49. <view class="echoPicture" v-else>
  50. <view v-for="item in fileList" :key="item" class="loop-item">
  51. {{ item }}
  52. <image class="image-sty" :src="item"></image>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="cf-appraise-anonymous">
  57. <view class="anonymous-text" @click="updateAnonymity">
  58. <text class="iconfont" :class="info.anonymous?'is-active':''">&#xe63b;</text>匿名评价
  59. </view>
  60. </view>
  61. </view>
  62. <view class="cf-appraise-btn pub-button is-bg large" v-if="!isEdit" @click="onApply">提交评价</view>
  63. </view>
  64. </pub-loading-view>
  65. </view>
  66. </template>
  67. <script lang="ts" setup>
  68. import { ref, PropType,watch } from 'vue'
  69. import dlg from '@/lib/dlg.ts'
  70. import rest from '@/stores/rest'
  71. import CfAppraiseStar from './CfAppraiseStar.vue'
  72. const emits = defineEmits(['update'])
  73. const props = defineProps({
  74. ptwybh: {
  75. type: String,
  76. default: ""
  77. },
  78. dataList: {
  79. type: Object as PropType<any>,
  80. default: () => ({})
  81. },
  82. isEdit: {
  83. type: Boolean,
  84. default: false
  85. }
  86. })
  87. const loaded = ref(false)
  88. const starText = [
  89. ['', '无效健康', '较差健康', '一般健康', '基本健康', '完全康复'],
  90. ['', '非常差', '差', '一般', '好', '非常好'],
  91. ['', '非常差', '差', '一般', '好', '非常好'],
  92. ['', '非常差', '差', '一般', '好', '非常好'],
  93. ]
  94. const info = ref({
  95. starVal: [0, 0, 0, 0],
  96. comprehensiveVal: 1,
  97. text: '',
  98. imgList: [],
  99. anonymous: true
  100. })
  101. const fileList = ref([])//用于显示图片列表
  102. const files = ref([]) //上传post
  103. // 上传图片
  104. const onSelectFile = async (res) => {
  105. if (!res.tempFilePaths.length) return;
  106. uni.showLoading({
  107. title: '正在上传...',
  108. mask: true
  109. });
  110. for (var i = 0; i < res.tempFilePaths.length; i++) {
  111. let uploadedFile = await rest.upload(res.tempFilePaths[i]);
  112. if (!uploadedFile) {
  113. dlg.error("上传失败,请重试!");
  114. uni.hideLoading();
  115. return;
  116. }
  117. files.value.push(uploadedFile);
  118. }
  119. uni.hideLoading();
  120. }
  121. // 删除图片
  122. const onDelFile = (val) => {
  123. if (val.index != -1) {
  124. files.value.splice(val.index, 1);
  125. }
  126. }
  127. // 修改
  128. const updateAnonymity = () => {
  129. info.value.anonymous = !info.value.anonymous
  130. }
  131. const onClickComprehensive = (val : number) => {
  132. info.value.comprehensiveVal = val
  133. }
  134. const onApply = async () => {
  135. const formData = {
  136. orderId: props.ptwybh,
  137. zhpj: info.value.comprehensiveVal,
  138. jyxg: info.value.starVal[0],
  139. kfys: info.value.starVal[1],
  140. jyzl: info.value.starVal[2],
  141. wlfw: info.value.starVal[3],
  142. content: info.value.text,
  143. image: JSON.stringify(files.value),
  144. anonymity: info.value.anonymous ? 1 : 0
  145. }
  146. info.value.imgList = files.value
  147. let fields = {
  148. 'orderId': '订单ID不能为空',
  149. 'zhpj': '综合评价不能为空',
  150. 'jyxg': '就医效果不能为空',
  151. 'kfys': '开方医生不能为空',
  152. 'jyzl': '煎药质量不能为空',
  153. 'wlfw': '物流服务不能为空'
  154. };
  155. for (let key in fields) {
  156. if (!formData[key]) {
  157. dlg.error(fields[key]);
  158. return;
  159. }
  160. }
  161. console.log("processedData", formData, files.value)
  162. await rest.post('/app-api/zyyp/prescription-evaluate/create',formData)
  163. dlg.success('操作成功')
  164. emits('update');
  165. }
  166. const getInfo = async()=> {
  167. info.value.comprehensiveVal = props.dataList.zhpj
  168. info.value.starVal = [props.dataList.jyxg,props.dataList.kfys,props.dataList.jyzl,props.dataList.wlfw]
  169. info.value.text = props.dataList.content
  170. info.value.imgList = props.dataList.imgList
  171. info.value.anonymous = props.dataList.anonymity == 1 ? true : false
  172. }
  173. watch(() => props.isEdit, (newValue) => {
  174. // console.log("watch isEdit", newValue);
  175. if (newValue) {
  176. getInfo();
  177. }
  178. }, { immediate: true });
  179. watch(() => props.dataList, (newValue) => {
  180. // console.log("watch dataList", newValue);
  181. if (props.isEdit) {
  182. getInfo();
  183. }
  184. }, { immediate: true });
  185. </script>
  186. <style lang="scss" scoped>
  187. .cf-appraise {
  188. padding: 0 $page-row-spacing;
  189. height: 100%;
  190. .cf-appraise-section {
  191. height: 100%;
  192. position: relative;
  193. display: flex;
  194. flex-direction: column;
  195. .cf-appraise-top-section {
  196. flex: 1;
  197. box-sizing: border-box;
  198. overflow-y: auto;
  199. .cf-appraise-top {
  200. background: #fff;
  201. padding: $uni-spacing-col-s3 $page-row-spacing;
  202. border-radius: 8rpx;
  203. .cf-appraise-top-title {
  204. text-align: center;
  205. font-size: $uni-font-size-xl;
  206. line-height: $uni-line-height-xl;
  207. font-weight: 600;
  208. }
  209. .cf-appraise-top-comprehensive {
  210. @include flex;
  211. margin-top: 40rpx;
  212. .cf-appraise-top-comprehensive-item {
  213. margin-left: 48rpx;
  214. @include flex;
  215. color: $uni-text-color-light;
  216. .iconfont {
  217. font-size: 48rpx;
  218. margin-right: 8rpx;
  219. background: linear-gradient(180deg, #B3B5B9 0%, #899AB9 100%);
  220. background-clip: text;
  221. text-fill-color: transparent;
  222. -webkit-background-clip: text;
  223. -webkit-text-fill-color: transparent;
  224. }
  225. &:nth-child(2) {
  226. margin-left: 32rpx;
  227. }
  228. &.is-active {
  229. color: $uni-text-color;
  230. .iconfont {
  231. background: linear-gradient(180deg, #FFBD48 0%, $uni-color-orange 100%);
  232. background-clip: text;
  233. text-fill-color: transparent;
  234. -webkit-background-clip: text;
  235. -webkit-text-fill-color: transparent;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. .cf-appraise-view {
  242. background: #fff;
  243. padding: $uni-spacing-col-s2 $uni-spacing-row-s3 $uni-spacing-col-s4;
  244. border-radius: 8rpx;
  245. margin-top: 24rpx;
  246. .cf-appraise-view-imgs {
  247. margin-top: 16rpx;
  248. image {
  249. width: 200rpx;
  250. height: 200rpx;
  251. border-radius: 8rpx;
  252. &+image {
  253. margin-left: 16rpx;
  254. }
  255. }
  256. }
  257. }
  258. .cf-appraise-edit {
  259. background: #fff;
  260. padding: $uni-spacing-col-s4 $uni-spacing-row-s4;
  261. border-radius: 8rpx;
  262. margin-top: 24rpx;
  263. color: $uni-text-color;
  264. .cf-appraise-edit-textarea {
  265. .textarea {
  266. width: 100%;
  267. height: 256rpx;
  268. font-size: $uni-font-size-lg;
  269. line-height: $uni-line-height-lg;
  270. :deep(.uni-textarea-placeholder) {
  271. color: $uni-text-color-light !important;
  272. }
  273. }
  274. }
  275. .picture-item {
  276. margin-top: 32rpx;
  277. .file-picker {
  278. .cf-appraise-edit-add {
  279. @include flex-center;
  280. width: 200rpx;
  281. height: 200rpx;
  282. background: linear-gradient(0deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)), #1E92F0;
  283. .iconfont {
  284. font-size: 76rpx;
  285. color: $uni-color-primary;
  286. }
  287. }
  288. }
  289. }
  290. .echoPicture {
  291. margin-top: 16rpx;
  292. display: flex;
  293. flex-wrap: wrap;
  294. padding-left: 2px;
  295. .loop-item {
  296. .image-sty {
  297. height: 200rpx;
  298. width: 200rpx;
  299. margin: 5px 2px 0 0px;
  300. }
  301. }
  302. }
  303. }
  304. .cf-appraise-anonymous {
  305. display: flex;
  306. margin: $uni-spacing-col-s4 0 $uni-spacing-col-s4 $uni-spacing-row-s4;
  307. // font-size: $uni-font-size-sm;
  308. // line-height: $uni-line-height-lg;
  309. .anonymous-text {
  310. @include flex;
  311. flex-wrap: 0;
  312. }
  313. .iconfont {
  314. margin-right: 16rpx;
  315. font-size: 40rpx;
  316. background: linear-gradient(180deg, #B3B5B9 0%, #899AB9 100%);
  317. background-clip: text;
  318. text-fill-color: transparent;
  319. -webkit-background-clip: text;
  320. -webkit-text-fill-color: transparent;
  321. &.is-active {
  322. background: linear-gradient(180deg, #46ACFF 0%, $uni-color-primary 100%);
  323. background-clip: text;
  324. text-fill-color: transparent;
  325. -webkit-background-clip: text;
  326. -webkit-text-fill-color: transparent;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. </style>