index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="模板名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入模板名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="副标题" prop="secondName">
  14. <el-input
  15. v-model="queryParams.secondName"
  16. placeholder="请输入副标题"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态" prop="status">
  23. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  24. <el-option
  25. v-for="dict in statusOptions"
  26. :key="dict.dictValue"
  27. :label="dict.dictLabel"
  28. :value="dict.dictValue"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  34. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-row :gutter="10" class="mb8">
  38. <el-col :span="1.5">
  39. <el-button
  40. type="primary"
  41. plain
  42. icon="el-icon-plus"
  43. size="mini"
  44. @click="handleAdd"
  45. v-hasPermi="['his:followTemp:add']"
  46. >新增</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['his:followTemp:edit']"
  57. >修改</el-button>
  58. </el-col>
  59. <el-col :span="1.5">
  60. <el-button
  61. type="danger"
  62. plain
  63. icon="el-icon-delete"
  64. size="mini"
  65. :disabled="multiple"
  66. @click="handleDelete"
  67. v-hasPermi="['his:followTemp:remove']"
  68. >删除</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="warning"
  73. plain
  74. icon="el-icon-download"
  75. size="mini"
  76. :loading="exportLoading"
  77. @click="handleExport"
  78. v-hasPermi="['his:followTemp:export']"
  79. >导出</el-button>
  80. </el-col>
  81. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  82. </el-row>
  83. <el-table v-loading="loading" border :data="followTempList" @selection-change="handleSelectionChange">
  84. <el-table-column type="selection" width="55" align="center" />
  85. <el-table-column label="模板名称" align="center" prop="name" />
  86. <el-table-column label="副标题" align="center" prop="secondName" />
  87. <el-table-column label="排序" align="center" prop="sort" />
  88. <el-table-column label="状态" align="center" prop="status">
  89. <template slot-scope="scope">
  90. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="创建时间" align="center" prop="createTime" />
  94. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  95. <template slot-scope="scope">
  96. <el-button
  97. size="mini"
  98. type="text"
  99. icon="el-icon-edit"
  100. @click="handleUpdate(scope.row)"
  101. v-hasPermi="['his:followTemp:edit']"
  102. >修改</el-button>
  103. <el-button
  104. size="mini"
  105. type="text"
  106. icon="el-icon-delete"
  107. @click="handleDelete(scope.row)"
  108. v-hasPermi="['his:followTemp:remove']"
  109. >删除</el-button>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <pagination
  114. v-show="total>0"
  115. :total="total"
  116. :page.sync="queryParams.pageNum"
  117. :limit.sync="queryParams.pageSize"
  118. @pagination="getList"
  119. />
  120. <!-- 添加或修改随访模板对话框 -->
  121. <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal ="false">
  122. <el-row>
  123. <el-col :span="3">
  124. <div style="margin-bottom: 20px;"> <el-button type="primary" @click='addQuestionnaire("1")' icon="el-icon-edit">单选题</el-button> </div>
  125. <div style="margin-bottom: 20px;"> <el-button type="primary" @click='addQuestionnaire("2")' icon="el-icon-edit">多选题</el-button></div>
  126. <div style="margin-bottom: 20px;"> <el-button type="primary" @click='addQuestionnaire("3")' icon="el-icon-edit">填空题</el-button> </div>
  127. </el-col>
  128. <el-col :span="21">
  129. <el-form ref="form" :model="form" :rules="rules" label-width="80px" >
  130. <el-row>
  131. <el-col :span="12">
  132. <el-form-item label="模板名称" prop="name">
  133. <el-input v-model="form.name" placeholder="请输入模板名称" />
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="12">
  137. <el-form-item label="副标题" prop="secondName">
  138. <el-input v-model="form.secondName" placeholder="请输入副标题" />
  139. </el-form-item>
  140. </el-col>
  141. </el-row>
  142. <el-row>
  143. <el-col :span="12">
  144. <el-form-item label="排序" prop="sort">
  145. <el-input-number v-model="form.sort" :min="0" label="请输入排序"></el-input-number>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="12">
  149. <el-form-item label="状态" prop="status">
  150. <el-radio-group v-model="form.status">
  151. <el-radio
  152. v-for="dict in statusOptions"
  153. :key="dict.dictValue"
  154. :label="parseInt(dict.dictValue)"
  155. >{{dict.dictLabel}}</el-radio>
  156. </el-radio-group>
  157. </el-form-item>
  158. </el-col>
  159. </el-row>
  160. <div style="height: 500px; overflow-y: auto;">
  161. <div style="height: 100%;">
  162. <div class="containerx">
  163. <span class="dashed-line"></span>
  164. <span class="centered-text"> 内容区域,请从左侧栏选择,编辑填充</span>
  165. <span class="dashed-line"></span>
  166. </div>
  167. <el-form-item label="模板内容" prop="formJson">
  168. <div v-show="list.length != 0">
  169. <div :class="'questionnaire_'+index" v-for="(item, index) in list" :key="index" >
  170. <div class="flex-1">
  171. <el-row>
  172. <el-col :span="1"><span :class="item.require ? 'require' : 'noRequire'">{{index+1}}.</span></el-col>
  173. <el-col :span="12"><input class="input-border" type="text" v-model="item.question" placeholder="请输入标题" /></el-col>
  174. <el-col :span="1" :offset="8"><i class="el-icon-delete-solid" @click="delQuestionnaire(index)" ></i></el-col>
  175. </el-row>
  176. <div>
  177. <!-- 判断为单选题型 -->
  178. <div v-if="'1' == item.type">
  179. <el-row v-for="(answerItem,i) in item.options" :key="i">
  180. <el-col :span="1"> <input type="radio" :name='"answerchoice["+index+"]"' class="answerchoice"/></el-col>
  181. <el-col :span="8"> <input class="input-border" type="text" v-model="item.options[i]"/></el-col>
  182. <el-col :span="1" :offset="12"><i class="el-icon-delete" @click='delAanwer("radio",index,i)' ></i></el-col>
  183. </el-row>
  184. <el-row>
  185. <el-col :span="4"> <el-link type="primary" class="el-icon-plus" :underline="false" @click='addAanwer("radio",index,i)'>添加单个选项</el-link></el-col>
  186. <el-col :span="1"> <el-checkbox v-model="item.require">必选</el-checkbox> </el-col>
  187. </el-row>
  188. </div>
  189. <!-- 判断为多选题型 -->
  190. <div v-if="'2' == item.type">
  191. <el-row v-for="(answerItem,i) in item.options" :key="i">
  192. <el-col :span="1"> <input type="checkbox" name="answer" class="answerchoice" /></el-col>
  193. <el-col :span="8"> <input class="input-border" type="text" v-model="item.options[i]" /></el-col>
  194. <el-col :span="1" :offset="12"> <i class="el-icon-delete" @click='delAanwer("checkbox",index,i)' ></i></el-col>
  195. </el-row>
  196. <el-row>
  197. <el-col :span="4"> <el-link type="primary" class="el-icon-plus" :underline="false" @click='addAanwer("radio",index,i)'>添加单个选项</el-link></el-col>
  198. <el-col :span="1"> <el-checkbox v-model="item.require">必选</el-checkbox> </el-col>
  199. </el-row>
  200. </div>
  201. <!-- 判断为填空题型 -->
  202. <div v-if="'3' == item.type">
  203. <el-row>
  204. <el-col :span="11" :offset="1"> <el-input type="textarea" :rows="2" :disabled="true"/></el-col>
  205. </el-row>
  206. <el-row>
  207. <el-col :span="4" > <el-checkbox v-model="item.require" style="margin-left: 6px;">必选</el-checkbox> </el-col>
  208. </el-row>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. </el-form-item>
  215. </div>
  216. </div>
  217. </el-form>
  218. </el-col>
  219. </el-row>
  220. <div slot="footer" class="dialog-footer">
  221. <el-button type="primary" @click="submitForm">确 定</el-button>
  222. <el-button @click="cancel">取 消</el-button>
  223. </div>
  224. </el-dialog>
  225. </div>
  226. </template>
  227. <script>
  228. import { listFollowTemp, getFollowTemp, delFollowTemp, addFollowTemp, updateFollowTemp, exportFollowTemp } from "@/api/his/followTemp";
  229. export default {
  230. name: "FollowTemp",
  231. data() {
  232. return {
  233. list: [],
  234. // 遮罩层
  235. loading: true,
  236. // 导出遮罩层
  237. exportLoading: false,
  238. // 选中数组
  239. ids: [],
  240. // 非单个禁用
  241. single: true,
  242. // 非多个禁用
  243. multiple: true,
  244. // 显示搜索条件
  245. showSearch: true,
  246. // 总条数
  247. total: 0,
  248. // 随访模板表格数据
  249. followTempList: [],
  250. // 弹出层标题
  251. title: "",
  252. // 是否显示弹出层
  253. open: false,
  254. // 状态字典
  255. statusOptions: [],
  256. // 查询参数
  257. queryParams: {
  258. pageNum: 1,
  259. pageSize: 10,
  260. name: null,
  261. secondName: null,
  262. status: null,
  263. createTime: null,
  264. },
  265. // 表单参数
  266. form: {},
  267. // 表单校验
  268. rules: {
  269. name: [
  270. { required: true, message: "模板名称不能为空", trigger: "blur" }
  271. ],
  272. secondName: [
  273. { required: true, message: "副标题不能为空", trigger: "blur" }
  274. ],
  275. status: [
  276. { required: true, message: "状态不能为空", trigger: "blur" }
  277. ],
  278. sort: [
  279. { required: true, message: "排序不能为空", trigger: "blur" }
  280. ],
  281. }
  282. };
  283. },
  284. created() {
  285. this.getList();
  286. this.getDicts("sys_company_status").then(response => {
  287. this.statusOptions = response.data;
  288. });
  289. },
  290. methods: {
  291. /** 查询随访模板列表 */
  292. getList() {
  293. this.loading = true;
  294. listFollowTemp(this.queryParams).then(response => {
  295. this.followTempList = response.rows;
  296. this.total = response.total;
  297. this.loading = false;
  298. });
  299. },
  300. // 取消按钮
  301. cancel() {
  302. this.open = false;
  303. this.reset();
  304. },
  305. // 表单重置
  306. reset() {
  307. this.form = {
  308. tempId: null,
  309. name: null,
  310. secondName: null,
  311. formJson: null,
  312. sort: null,
  313. status: 1,
  314. createBy: null,
  315. createTime: null,
  316. updateBy: null,
  317. updateTime: null
  318. };
  319. this.list=[];
  320. this.resetForm("form");
  321. },
  322. /** 搜索按钮操作 */
  323. handleQuery() {
  324. this.queryParams.pageNum = 1;
  325. this.getList();
  326. },
  327. /** 重置按钮操作 */
  328. resetQuery() {
  329. this.resetForm("queryForm");
  330. this.handleQuery();
  331. },
  332. // 多选框选中数据
  333. handleSelectionChange(selection) {
  334. this.ids = selection.map(item => item.tempId)
  335. this.single = selection.length!==1
  336. this.multiple = !selection.length
  337. },
  338. /** 新增按钮操作 */
  339. handleAdd() {
  340. this.reset();
  341. this.open = true;
  342. this.title = "添加随访模板";
  343. },
  344. /** 修改按钮操作 */
  345. handleUpdate(row) {
  346. this.reset();
  347. const tempId = row.tempId || this.ids
  348. getFollowTemp(tempId).then(response => {
  349. this.form = response.data;
  350. this.open = true;
  351. this.title = "修改随访模板";
  352. if(this.form.formJson!=null){
  353. this.list=JSON.parse(this.form.formJson );
  354. }
  355. });
  356. },
  357. /** 提交按钮 */
  358. submitForm() {
  359. if(this.list==null||this.list==''){
  360. this.msgError("模板内容不能为空");
  361. return;
  362. }
  363. this.form.formJson=JSON.stringify(this.list);
  364. this.$refs["form"].validate(valid => {
  365. if (valid) {
  366. if (this.form.tempId != null) {
  367. updateFollowTemp(this.form).then(response => {
  368. this.msgSuccess("修改成功");
  369. this.open = false;
  370. this.getList();
  371. });
  372. } else {
  373. addFollowTemp(this.form).then(response => {
  374. this.msgSuccess("新增成功");
  375. this.open = false;
  376. this.getList();
  377. });
  378. }
  379. }
  380. });
  381. },
  382. /** 删除按钮操作 */
  383. handleDelete(row) {
  384. const tempIds = row.tempId || this.ids;
  385. this.$confirm('是否确认删除随访模板编号为"' + tempIds + '"的数据项?', "警告", {
  386. confirmButtonText: "确定",
  387. cancelButtonText: "取消",
  388. type: "warning"
  389. }).then(function() {
  390. return delFollowTemp(tempIds);
  391. }).then(() => {
  392. this.getList();
  393. this.msgSuccess("删除成功");
  394. }).catch(() => {});
  395. },
  396. /** 导出按钮操作 */
  397. handleExport() {
  398. const queryParams = this.queryParams;
  399. this.$confirm('是否确认导出所有随访模板数据项?', "警告", {
  400. confirmButtonText: "确定",
  401. cancelButtonText: "取消",
  402. type: "warning"
  403. }).then(() => {
  404. this.exportLoading = true;
  405. return exportFollowTemp(queryParams);
  406. }).then(response => {
  407. this.download(response.msg);
  408. this.exportLoading = false;
  409. }).catch(() => {});
  410. },
  411. addQuestionnaire(type, index, operation) {
  412. // 添加单选题
  413. if (type == '1') {
  414. var singleChoice = {
  415. question: '请输入问题',
  416. options: ['选项1', '选项2'],
  417. type: '1',
  418. // sort: this.list.length + 1,
  419. require:false,
  420. }
  421. // 在当前题下方添加
  422. if (index != undefined && undefined == operation) {
  423. this.list.splice(index + 1, 0, 1)
  424. }
  425. this.list.push(singleChoice)
  426. }
  427. // 添加多选题
  428. else if (type == '2') {
  429. var mutipleChoice = {
  430. question: '请输入问题',
  431. options: ['选项1', '选项2'],
  432. type: '2',
  433. // sort: this.list.length + 1
  434. require:false,
  435. }
  436. // 在当前题下方添加
  437. if (index != undefined && undefined == operation) {
  438. this.list.splice(index + 1, 0, mutipleChoice)
  439. }
  440. this.list.push(mutipleChoice)
  441. }
  442. // 添加多选题 end
  443. else if (type == '3') {
  444. var scoring = {
  445. question: '请输入问题',
  446. options: null,
  447. type: '3',
  448. // sort: this.list.length + 1
  449. require:false,
  450. }
  451. // 在当前题下方添加
  452. if (index != undefined && undefined == operation) {
  453. this.list.splice(index + 1, 0, scoring)
  454. }
  455. this.list.push(scoring)
  456. }
  457. },
  458. //删除一题
  459. delQuestionnaire(id) {
  460. this.list.splice(id, 1)
  461. },
  462. //添加一项答案
  463. addAanwer(type, index, option) {
  464. var options = this.list[index].options.length + 1
  465. this.list[index].options.push('选项' + options)
  466. },
  467. //删除一项答案
  468. delAanwer(type, index, option) {
  469. if (this.list[index].options.length > 2) {
  470. this.list[index].options.splice(option, 1)
  471. } else {
  472. this.msgError("至少留下两项");
  473. }
  474. }
  475. }
  476. };
  477. </script>
  478. <style>
  479. .btn-bgWhite {
  480. border: 1px solid #999999;
  481. background: #fff;
  482. border-radius: 2px;
  483. }
  484. .btn-bgWhite:hover,
  485. .btn-bgBlue:hover,
  486. .btn-bgYello:hover {
  487. background: #333;
  488. color: #fff;
  489. }
  490. .btn-bgBlue {
  491. background: #3582f8;
  492. border-radius: 2px;
  493. color: #fff;
  494. }
  495. .btn-bgYello {
  496. background: #e7a42f;
  497. border-radius: 2px;
  498. color: #fff;
  499. }
  500. .text-right {
  501. text-align: right;
  502. }
  503. .text-left {
  504. text-align: left;
  505. }
  506. .form-control {
  507. /* height: 40px; */
  508. background: #ffffff;
  509. border: 1px solid #d8d8d8;
  510. border-radius: 3px;
  511. box-shadow: none;
  512. margin: 15px;
  513. padding: 5px;
  514. }
  515. input:focus {
  516. outline: none;
  517. }
  518. .input-group-fan .form-control {
  519. margin: 0;
  520. padding: 10px 15px;
  521. }
  522. .input-group-fan select {
  523. display: block;
  524. height: 40px;
  525. width: 330px;
  526. border: 1px solid #d8d8d8;
  527. padding: 0 10px;
  528. border-radius: 3px;
  529. }
  530. .input-group-fan select option {
  531. padding: 5px;
  532. }
  533. .input-group-fan label {
  534. font-size: 14px;
  535. color: #333333;
  536. }
  537. .input-group-fan {
  538. margin: 15px 0;
  539. width: 100%;
  540. }
  541. .input-group-fan input {
  542. float: none !important;
  543. width: 500px !important;
  544. display: block !important;
  545. }
  546. .input-border {
  547. border: 1px dashed #eee;
  548. margin-bottom: 10px !important;
  549. padding: 5px;
  550. width: 400px;
  551. }
  552. .require:before {
  553. content: '* ';
  554. color: red;
  555. }
  556. .noRequire:before{
  557. content: '* ';
  558. color: white;
  559. }
  560. .answerchoice{
  561. margin-left: 6px;
  562. }
  563. .containerx {
  564. height: 50px;
  565. display: flex;
  566. align-items: center;
  567. justify-content: center;
  568. }
  569. .dashed-line {
  570. flex-grow: 1;
  571. border-top: 1px dashed #000;
  572. }
  573. .centered-text {
  574. margin: 0 10px;
  575. color: #07a8ff;
  576. }
  577. </style>