CfAppraise.vue 10 KB

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