SeeQuestionnaire.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <script setup lang="ts">
  2. import { ref, reactive, onMounted } from 'vue';
  3. const props = defineProps<{
  4. data?: any;
  5. }>();
  6. const emits = defineEmits<{
  7. submit: [data?: any];
  8. back: [];
  9. }>();
  10. // 问卷数据结构
  11. interface Question {
  12. id: string;
  13. content: string;
  14. required?: boolean;
  15. }
  16. interface Section {
  17. id: string;
  18. title: string;
  19. questions: Question[];
  20. }
  21. // 表单数据
  22. const form = reactive({
  23. title: '就诊体验满意度', // 问卷标题
  24. introduction:
  25. '尊敬的患者及家属:\n 您好!感谢您选择我院就诊。为了不断的提升我们的医院服务质量,更好地为您和其他患者提供优质、高效的医疗服务,我们特开展此次就诊满意度回访调查,您的反馈对我们至关重要。请您根据实际就诊体验,恳请您抽出宝贵时间,根据您的实际就诊体验填写以下内容。我们将对您的信息严格保密。感谢您的支持与配合!', // 介绍文字
  26. scoreExplanation: '1分表示非常不满意, 2分表示不满意, 3分表示一般, 4分表示满意, 5分表示非常满意', // 分数说明
  27. sections: [
  28. {
  29. id: '1',
  30. title: '一、就诊环境评价',
  31. questions: [
  32. { id: '1', content: '医院门诊 / 住院部的整洁度:', required: true },
  33. { id: '2', content: '医院的通风情况:', required: true },
  34. { id: '3', content: '医院的采光情况:', required: true },
  35. { id: '4', content: '医院的噪音控制:', required: true },
  36. { id: '5', content: '候诊区域的舒适度 (座椅、空间等)', required: true },
  37. ],
  38. },
  39. ] as Section[],
  40. otherComments: '', // 其他意见
  41. });
  42. // 初始化数据
  43. onMounted(() => {
  44. if (props.data) {
  45. if (props.data.title) form.title = props.data.title;
  46. if (props.data.introduction) form.introduction = props.data.introduction;
  47. if (props.data.scoreExplanation) form.scoreExplanation = props.data.scoreExplanation;
  48. if (props.data.sections) form.sections = props.data.sections;
  49. if (props.data.otherComments) form.otherComments = props.data.otherComments;
  50. }
  51. });
  52. </script>
  53. <template>
  54. <div class="questionnaire-editor-container">
  55. <!-- 表单内容 -->
  56. <div class="form-content">
  57. <a-form ref="formRef" :model="form" layout="vertical">
  58. <!-- 问卷标题 -->
  59. <h1 class="questionnaire-title-section">
  60. {{ form.title }}
  61. </h1>
  62. <!-- 介绍文字 -->
  63. <div class="introduction-section">
  64. {{ form.introduction }}
  65. </div>
  66. <!-- 分数说明 -->
  67. <div class="score-explanation-section">
  68. <div class="label">分数说明:</div>
  69. <div class="score-explanation-input label">
  70. {{ form.scoreExplanation }}
  71. </div>
  72. </div>
  73. <!-- 章节列表 -->
  74. <div class="sections-container">
  75. <div v-for="section in form.sections" :key="section.id" class="section-item">
  76. <!-- 章节标题 -->
  77. <!-- <div class="section-header"> -->
  78. <h2 class="section-title-input label">
  79. {{ section.title }}
  80. </h2>
  81. <!-- 问题列表 -->
  82. <div class="questions-list">
  83. <div v-for="(question, questionIndex) in section.questions" :key="question.id" class="question-item">
  84. <div class="question-content">
  85. <span class="question-number">{{ questionIndex + 1 }}、</span>
  86. <div class="question-input label">
  87. {{ question.content }}
  88. </div>
  89. </div>
  90. <!-- 评分选项(1-5分) -->
  91. <div class="score-options">
  92. <a-radio-group :value="1">
  93. <a-radio :value="1">1分</a-radio>
  94. <a-radio :value="2">2分</a-radio>
  95. <a-radio :value="3">3分</a-radio>
  96. <a-radio :value="4">4分</a-radio>
  97. <a-radio :value="5">5分</a-radio>
  98. </a-radio-group>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <!-- 其他意见 -->
  105. <div class="other-comments-section">
  106. <div class="other-comments-label">其他意见:</div>
  107. <a-textarea
  108. v-model:value="form.otherComments"
  109. placeholder="请给我们留言您的其他意见"
  110. :rows="4"
  111. class="other-comments-input"
  112. />
  113. </div>
  114. </a-form>
  115. </div>
  116. </div>
  117. </template>
  118. <style scoped lang="scss">
  119. .questionnaire-editor-container {
  120. // border: 1px solid #f0f0f0;
  121. padding: 24px;
  122. background: #fff;
  123. height: 100%;
  124. display: flex;
  125. flex-direction: column;
  126. }
  127. .form-content {
  128. flex: 1;
  129. overflow: auto;
  130. margin-bottom: 24px;
  131. max-width: 800px;
  132. margin: 0 auto 24px;
  133. width: 100%;
  134. }
  135. // 问卷标题
  136. .questionnaire-title-section {
  137. text-align: center;
  138. margin-bottom: 32px;
  139. .title-input {
  140. font-size: 24px;
  141. font-weight: bold;
  142. text-align: center;
  143. :deep(.ant-input) {
  144. font-size: 24px;
  145. font-weight: bold;
  146. text-align: center;
  147. border: none;
  148. border-bottom: 2px solid #d9d9d9;
  149. border-radius: 0;
  150. padding: 12px 0;
  151. background: transparent;
  152. &:focus,
  153. &:hover {
  154. border-bottom-color: #40a9ff;
  155. box-shadow: none;
  156. }
  157. }
  158. }
  159. }
  160. // 介绍文字
  161. .introduction-section {
  162. margin-bottom: 24px;
  163. .introduction-textarea {
  164. :deep(.ant-input) {
  165. font-size: 14px;
  166. line-height: 2;
  167. white-space: pre-wrap;
  168. // border: 1px solid #d9d9d9;
  169. padding: 12px;
  170. // border-radius: 4px;
  171. }
  172. }
  173. }
  174. // 分数说明
  175. .score-explanation-section {
  176. margin-bottom: 24px;
  177. display: flex;
  178. align-items: center;
  179. gap: 8px;
  180. .label {
  181. font-size: 14px;
  182. color: rgba(0, 0, 0, 0.85);
  183. font-weight: 500;
  184. white-space: nowrap;
  185. }
  186. .score-explanation-input {
  187. flex: 1;
  188. :deep(.ant-input) {
  189. font-size: 14px;
  190. }
  191. }
  192. }
  193. // 章节容器
  194. .sections-container {
  195. display: flex;
  196. flex-direction: column;
  197. gap: 32px;
  198. }
  199. // 章节项
  200. .section-item {
  201. border: 1px solid #f0f0f0;
  202. border-radius: 4px;
  203. padding: 16px;
  204. background: #fafafa;
  205. }
  206. // 章节标题
  207. .section-header {
  208. display: flex;
  209. align-items: center;
  210. gap: 12px;
  211. margin-bottom: 16px;
  212. .section-title-input {
  213. flex: 1;
  214. :deep(.ant-input) {
  215. font-size: 16px;
  216. font-weight: bold;
  217. border: none;
  218. background: transparent;
  219. padding: 4px 8px;
  220. border-bottom: 1px dashed transparent;
  221. &:focus,
  222. &:hover {
  223. border-bottom-color: #d9d9d9;
  224. background: #fff;
  225. }
  226. }
  227. }
  228. .delete-section-btn {
  229. flex-shrink: 0;
  230. }
  231. }
  232. // 问题列表
  233. .questions-list {
  234. display: flex;
  235. flex-direction: column;
  236. gap: 16px;
  237. }
  238. // 问题项
  239. .question-item {
  240. background: #fff;
  241. padding: 16px;
  242. border-radius: 4px;
  243. border: 1px solid #e8e8e8;
  244. }
  245. // 问题内容
  246. .question-content {
  247. display: flex;
  248. align-items: center;
  249. gap: 8px;
  250. margin-bottom: 12px;
  251. .question-number {
  252. font-size: 14px;
  253. color: rgba(0, 0, 0, 0.85);
  254. font-weight: 500;
  255. flex-shrink: 0;
  256. }
  257. .question-input {
  258. flex: 1;
  259. font-weight: bold;
  260. :deep(.ant-input) {
  261. font-size: 14px;
  262. border: none;
  263. border-bottom: 1px dashed transparent;
  264. padding: 4px 8px;
  265. &:focus,
  266. &:hover {
  267. border-bottom-color: #d9d9d9;
  268. }
  269. }
  270. }
  271. .delete-question-btn {
  272. flex-shrink: 0;
  273. }
  274. }
  275. // 评分选项
  276. .score-options {
  277. display: flex;
  278. align-items: center;
  279. gap: 12px;
  280. padding-left: 24px;
  281. flex-wrap: wrap;
  282. :deep(.ant-radio-group) {
  283. display: flex;
  284. gap: 24px;
  285. flex-wrap: wrap;
  286. }
  287. :deep(.ant-radio-wrapper) {
  288. font-size: 14px;
  289. margin-right: 0;
  290. }
  291. .score-hint {
  292. font-size: 12px;
  293. color: rgba(0, 0, 0, 0.45);
  294. font-style: italic;
  295. margin-left: auto;
  296. }
  297. }
  298. // 其他意见
  299. .other-comments-section {
  300. margin-top: 32px;
  301. padding: 16px;
  302. border: 1px solid #e8e8e8;
  303. border-radius: 4px;
  304. background: #fff;
  305. .other-comments-label {
  306. font-size: 14px;
  307. color: rgba(0, 0, 0, 0.85);
  308. font-weight: 500;
  309. margin-bottom: 12px;
  310. }
  311. .other-comments-input {
  312. :deep(.ant-input) {
  313. font-size: 14px;
  314. }
  315. }
  316. }
  317. :deep(.ant-input),
  318. :deep(.ant-textarea),
  319. :deep(.ant-select-selector) {
  320. border-color: #d9d9d9;
  321. }
  322. </style>