CfAppraise.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. <uni-file-picker readonly :value="info.imgList" file-mediatype="image">
  32. </uni-file-picker>
  33. </view>
  34. </view>
  35. <view class="cf-appraise-edit" v-else>
  36. <view class="cf-appraise-edit-textarea">
  37. <!-- <textarea v-model="info.text" class="textarea" :disabled="false" placeholder-style="color:#B3B5B9"
  38. maxlength="-1" placeholder="展开说说您对“中医用药一件事”的想法吧..." /> -->
  39. <uni-easyinput class="pub-input" :inputBorder="false" autoHeight trim="all" :adjust-position="false"
  40. type="textarea" maxlength="-1" v-model="info.text" placeholder="展开说说您对“中医用药一件事”的想法吧..."></uni-easyinput>
  41. </view>
  42. <!-- 最多三张 -->
  43. <view class="picture-item">
  44. <uni-file-picker class="file-picker" limit="3" :auto-upload="false" :del-icon="true"
  45. file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image" v-model="fileList" @select="onSelectFile"
  46. @delete="onDelFile">
  47. <view class="cf-appraise-edit-add">
  48. <text class="iconfont">&#xe69f;</text>
  49. </view>
  50. </uni-file-picker>
  51. </view>
  52. </view>
  53. <view class="cf-appraise-anonymous">
  54. <view class="anonymous-text" @click="updateAnonymity">
  55. <text class="iconfont" :class="info.anonymous?'is-active':''">&#xe63b;</text>匿名评价
  56. </view>
  57. </view>
  58. </view>
  59. <view class="cf-appraise-btn pub-button is-bg large" v-if="!isEdit" @click="onApply">提交评价</view>
  60. </view>
  61. </pub-loading-view>
  62. </view>
  63. </template>
  64. <script lang="ts" setup>
  65. import { ref, PropType, watch } from 'vue'
  66. import dlg from '@/lib/dlg.ts'
  67. import rest from '@/stores/rest'
  68. import CfAppraiseStar from './CfAppraiseStar.vue'
  69. const emits = defineEmits(['update'])
  70. const props = defineProps({
  71. ptwybh: {
  72. type: String,
  73. default: ""
  74. },
  75. dataList: {
  76. type: Object as PropType<any>,
  77. default: () => ({})
  78. },
  79. isEdit: {
  80. type: Boolean,
  81. default: false
  82. }
  83. })
  84. const loaded = ref(false)
  85. const starText = [
  86. ['', '无效健康', '较差健康', '一般健康', '基本健康', '完全康复'],
  87. ['', '非常差', '差', '一般', '好', '非常好'],
  88. ['', '非常差', '差', '一般', '好', '非常好'],
  89. ['', '非常差', '差', '一般', '好', '非常好'],
  90. ]
  91. const info = ref({
  92. starVal: [0, 0, 0, 0],
  93. comprehensiveVal: 3,
  94. text: '',
  95. imgList: [],
  96. anonymous: true
  97. })
  98. const fileList = ref([])//用于显示图片列表
  99. const files = ref([]) //上传post
  100. // 上传图片
  101. const onSelectFile = async (res) => {
  102. if (!res.tempFilePaths.length) return;
  103. uni.showLoading({
  104. title: '正在上传...',
  105. mask: true
  106. });
  107. for (var i = 0; i < res.tempFilePaths.length; i++) {
  108. let uploadedFile = await rest.upload(res.tempFilePaths[i]);
  109. if (!uploadedFile) {
  110. dlg.error("上传失败,请重试!");
  111. uni.hideLoading();
  112. return;
  113. }
  114. files.value.push(uploadedFile);
  115. }
  116. uni.hideLoading();
  117. }
  118. // 删除图片
  119. const onDelFile = (val) => {
  120. if (val.index != -1) {
  121. files.value.splice(val.index, 1);
  122. }
  123. }
  124. // 修改
  125. const updateAnonymity = () => {
  126. if (props.isEdit) return
  127. info.value.anonymous = !info.value.anonymous
  128. }
  129. const onClickComprehensive = (val : number) => {
  130. if (props.isEdit) return
  131. info.value.comprehensiveVal = val
  132. }
  133. const onApply = async () => {
  134. const formData = {
  135. orderId: props.ptwybh,
  136. zhpj: info.value.comprehensiveVal,
  137. jyxg: info.value.starVal[0],
  138. kfys: info.value.starVal[1],
  139. jyzl: info.value.starVal[2],
  140. wlfw: info.value.starVal[3],
  141. content: info.value.text,
  142. image: JSON.stringify(files.value),
  143. anonymity: info.value.anonymous ? 1 : 0
  144. }
  145. info.value.imgList = files.value
  146. let fields = {
  147. 'orderId': '订单ID不能为空',
  148. 'zhpj': '综合评价不能为空',
  149. 'jyxg': '就医效果不能为空',
  150. 'kfys': '开方医生不能为空',
  151. 'jyzl': '煎药质量不能为空',
  152. 'wlfw': '物流服务不能为空'
  153. };
  154. for (let key in fields) {
  155. if (!formData[key]) {
  156. dlg.error(fields[key]);
  157. return;
  158. }
  159. }
  160. console.log("processedData", formData, files.value)
  161. await rest.post('/app-api/zyyp/prescription-evaluate/create', formData)
  162. dlg.success('操作成功')
  163. emits('update');
  164. }
  165. const getInfo = async () => {
  166. info.value.comprehensiveVal = props.dataList.zhpj
  167. info.value.starVal = [props.dataList.jyxg, props.dataList.kfys, props.dataList.jyzl, props.dataList.wlfw]
  168. info.value.text = props.dataList.content
  169. info.value.imgList = props.dataList.imgList.map((item : string) => {
  170. return { url: item }
  171. })
  172. info.value.anonymous = props.dataList.anonymity == 1 ? true : false
  173. }
  174. watch(() => props.isEdit, (newValue) => {
  175. if (newValue) {
  176. getInfo();
  177. }
  178. }, { immediate: true });
  179. watch(() => props.dataList, (newValue) => {
  180. if (props.isEdit) {
  181. getInfo();
  182. }
  183. }, { immediate: true });
  184. </script>
  185. <style lang="scss" scoped>
  186. .cf-appraise {
  187. padding: 0 $page-row-spacing;
  188. height: 100%;
  189. .cf-appraise-section {
  190. height: 100%;
  191. position: relative;
  192. display: flex;
  193. flex-direction: column;
  194. .cf-appraise-top-section {
  195. flex: 1;
  196. box-sizing: border-box;
  197. overflow-y: auto;
  198. min-height: 300rpx;
  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 !important;
  250. height: 200rpx !important;
  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. :deep(.uni-easyinput__content-textarea) {
  275. margin: 8rpx 0 4rpx;
  276. height: 120rpx;
  277. min-height: 120rpx;
  278. .uni-easyinput__placeholder-class {
  279. font-size: $uni-font-size-lg;
  280. line-height: $uni-line-height-lg;
  281. color: $uni-text-color-light;
  282. }
  283. .uni-textarea-textarea {
  284. font-size: $uni-font-size-lg;
  285. line-height: $uni-line-height-lg;
  286. color: $uni-text-color;
  287. }
  288. }
  289. }
  290. .picture-item {
  291. margin-top: 32rpx;
  292. .file-picker {
  293. .cf-appraise-edit-add {
  294. @include flex-center;
  295. width: 200rpx;
  296. height: 200rpx;
  297. background: linear-gradient(0deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)), #1E92F0;
  298. .iconfont {
  299. font-size: 76rpx;
  300. color: $uni-color-primary;
  301. }
  302. }
  303. }
  304. }
  305. .echoPicture {
  306. margin-top: 16rpx;
  307. display: flex;
  308. flex-wrap: wrap;
  309. padding-left: 2px;
  310. .loop-item {
  311. .image-sty {
  312. height: 200rpx;
  313. width: 200rpx;
  314. margin: 5px 2px 0 0px;
  315. }
  316. }
  317. }
  318. }
  319. .cf-appraise-anonymous {
  320. display: flex;
  321. margin: $uni-spacing-col-s4 0 $uni-spacing-col-s4 $uni-spacing-row-s4;
  322. // font-size: $uni-font-size-sm;
  323. // line-height: $uni-line-height-lg;
  324. .anonymous-text {
  325. @include flex;
  326. flex-wrap: 0;
  327. }
  328. .iconfont {
  329. margin-right: 16rpx;
  330. font-size: 40rpx;
  331. background: linear-gradient(180deg, #B3B5B9 0%, #899AB9 100%);
  332. background-clip: text;
  333. text-fill-color: transparent;
  334. -webkit-background-clip: text;
  335. -webkit-text-fill-color: transparent;
  336. &.is-active {
  337. background: linear-gradient(180deg, #46ACFF 0%, $uni-color-primary 100%);
  338. background-clip: text;
  339. text-fill-color: transparent;
  340. -webkit-background-clip: text;
  341. -webkit-text-fill-color: transparent;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. </style>