modelForm.vue 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672
  1. <style lang="scss" scoped>
  2. .content {
  3. display: flex;
  4. padding: 0;
  5. .content-item {
  6. flex: 1;
  7. padding: 20px;
  8. &.middle {
  9. border-left: 2px solid #d8d8d8;
  10. border-right: 2px solid #d8d8d8;
  11. }
  12. &.right,
  13. &.middle {
  14. flex: 2;
  15. }
  16. .item-title {
  17. font-size: 14px;
  18. font-weight: bold;
  19. color: #666666;
  20. margin-bottom: 20px;
  21. }
  22. .el-row {
  23. margin-top: 20px;
  24. }
  25. .model {
  26. width: 80px;
  27. height: 80px;
  28. display: flex;
  29. flex-direction: column;
  30. align-items: center;
  31. justify-content: space-evenly;
  32. &:hover {
  33. cursor: pointer;
  34. background: #f5faff;
  35. }
  36. img {
  37. height: 28px;
  38. width: 28px;
  39. }
  40. span {
  41. font-size: 14px;
  42. color: #666666;
  43. // margin-top:19px;
  44. }
  45. }
  46. .el-form {
  47. margin-bottom: 20px;
  48. .el-form-item {
  49. background: #f5faff;
  50. padding: 10px 20px;
  51. margin-bottom: 5px;
  52. /deep/.el-form-item__label {
  53. font-size: 16px;
  54. color: #666666;
  55. display: block;
  56. line-height: 20px;
  57. margin-bottom: 10px;
  58. text-align: left;
  59. }
  60. /deep/.el-form-item__content {
  61. line-height: 20px !important;
  62. margin-right: 160px;
  63. position: relative;
  64. font,
  65. .drag {
  66. position: absolute;
  67. right: -145px;
  68. }
  69. font {
  70. top: 0px;
  71. color: #3895fe;
  72. font-size: 12px;
  73. span {
  74. margin-left: 5px;
  75. cursor: pointer;
  76. }
  77. }
  78. .drag {
  79. right: -160px;
  80. bottom: -3px;
  81. }
  82. div {
  83. font-size: 16px;
  84. color: #333333;
  85. }
  86. .el-radio,
  87. .el-checkbox {
  88. margin-right: 32px;
  89. // height: 32px;
  90. line-height: 20px;
  91. }
  92. .el-radio-group,
  93. .el-checkbox-group {
  94. display: flex;
  95. flex-direction: column;
  96. }
  97. .cus_select .el-radio,
  98. .el-radio__input {
  99. white-space: normal;
  100. }
  101. .cus_select .el-checkbox,
  102. .el-checkbox__input {
  103. white-space: normal;
  104. }
  105. .cus_select .el-checkbox__label {
  106. display: inline;
  107. }
  108. .el-radio__label,
  109. .el-checkbox__label {
  110. display: inline-block !important;
  111. width: 93%;
  112. vertical-align: top;
  113. }
  114. .el-radio,
  115. .el-checkbox {
  116. margin-bottom: 10px;
  117. }
  118. }
  119. /deep/.el-form-item__label {
  120. float: none;
  121. font-weight: bold;
  122. }
  123. &.text {
  124. /deep/.el-form-item__content {
  125. // margin-left:60px;
  126. }
  127. }
  128. }
  129. }
  130. // 右边
  131. .phone {
  132. width: 350px;
  133. height: 713px;
  134. background: url("../../assets/survey_bg.png") no-repeat;
  135. background-size: 100% auto;
  136. margin: auto;
  137. }
  138. .item-main {
  139. height: 551px;
  140. width: 315px;
  141. background: #ffffff;
  142. border: 1px solid #ddd;
  143. overflow: auto;
  144. position: relative;
  145. top: 80px;
  146. left: 21px;
  147. // display: none;
  148. // border: 1px solid #DDDDDD;
  149. // box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.13);
  150. border-radius: 5px;
  151. overflow: auto;
  152. .el-form.over_y {
  153. border: none;
  154. overflow: visible;
  155. }
  156. }
  157. // label样式
  158. .edit_label {
  159. /deep/.el-input__inner {
  160. background: #f5faff;
  161. border: 0px;
  162. padding: 0px;
  163. }
  164. }
  165. /deep/.opicon {
  166. font-weight: bold;
  167. padding: 5px;
  168. color: #3895fe;
  169. }
  170. .tpl_title {
  171. font-size: 18px;
  172. margin: 20px;
  173. }
  174. .tpl_form {
  175. margin: 0px;
  176. border: 1px solid #ccc;
  177. border-radius: 20px;
  178. /deep/.el-form-item {
  179. background: none;
  180. }
  181. /deep/.el-form-item__content {
  182. width: 100%;
  183. }
  184. }
  185. .survey_logo {
  186. width: 145px;
  187. position: relative;
  188. top: 5px;
  189. left: 20px;
  190. }
  191. .item_require {
  192. position: absolute;
  193. top: 0px;
  194. right: 35px !important;
  195. /deep/.el-checkbox__label {
  196. padding-left: 5px;
  197. // color:red;
  198. }
  199. }
  200. .require::before {
  201. content: "*";
  202. color: #f56c6c;
  203. margin-right: 4px;
  204. position: absolute;
  205. left: -10px;
  206. }
  207. }
  208. /deep/.radio .el-input {
  209. width: 85%;
  210. }
  211. /deep/.checkbox .el-input {
  212. width: 85%;
  213. }
  214. // 操作按钮
  215. .ctl_btn {
  216. display: inline-block;
  217. width: 28px;
  218. position: absolute;
  219. top: -5px;
  220. }
  221. .ctl_btn_change {
  222. top: 20px;
  223. right: -15px;
  224. color: green;
  225. width: 80px;
  226. font-size: 16px;
  227. }
  228. .ctl_btn_note {
  229. right: 20px;
  230. color: #ffb800;
  231. }
  232. .ctl_btn_edit {
  233. right: 20px;
  234. color: green;
  235. }
  236. .ctl_btn_del {
  237. right: -15px;
  238. color: red;
  239. }
  240. .ctl_btn_move {
  241. font-size: 22px;
  242. }
  243. .gdrag {
  244. bottom: 15px !important;
  245. }
  246. // 注释弹窗
  247. /deep/.noteDialog .el-form-item__content {
  248. margin-right: 0px !important;
  249. margin-left: 0px !important;
  250. }
  251. // /deep/.noteDialog .el-dialog{
  252. // margin-top:20vh!important;
  253. // }
  254. /deep/.noteDialog .el-dialog__body {
  255. padding: 10px 20px !important;
  256. }
  257. .img_list {
  258. li {
  259. display: inline-block;
  260. min-width: 140px;
  261. height: 148px;
  262. margin: 10px;
  263. position: relative;
  264. overflow: hidden;
  265. img {
  266. height: 100%;
  267. }
  268. .el-icon-delete {
  269. color: red;
  270. font-size: 18px;
  271. cursor: pointer;
  272. }
  273. .move {
  274. position: absolute;
  275. bottom: 0;
  276. left: 0;
  277. width: 100%;
  278. text-align: center;
  279. background: rgba(0, 0, 0, 0.527);
  280. color: #fff;
  281. cursor: pointer;
  282. }
  283. }
  284. }
  285. //
  286. /deep/.group .el-form-item__content {
  287. margin-right: 0px !important;
  288. }
  289. .active_item {
  290. border: 2px solid #3a8ee6;
  291. }
  292. // 提示信息展示
  293. .noteInfoDialog {
  294. width: 90%;
  295. margin: 0 auto;
  296. height: 300px;
  297. border: 1px solid #ccc;
  298. position: absolute;
  299. top: 10vh;
  300. left: 5%;
  301. background: #ffffff;
  302. }
  303. .noteInfoDialog .body {
  304. width: 100%;
  305. margin: 0 auto;
  306. height: 300px;
  307. // border:1px solid red;
  308. position: absolute;
  309. // top:10vh;
  310. // left:5%;
  311. }
  312. }
  313. .tool_text {
  314. width: 315px;
  315. p {
  316. margin-bottom: 10px;
  317. }
  318. .toolText_img {
  319. img {
  320. width: 100px;
  321. height: 100px;
  322. margin-bottom: 5px;
  323. margin-right: 5px;
  324. }
  325. // img:nth-child(odd) {
  326. // margin-right: 5px;
  327. // }
  328. }
  329. }
  330. .group_title {
  331. font-size: 16px;
  332. font-weight: bold;
  333. padding: 10px 20px;
  334. }
  335. .groupMain {
  336. border: 1px solid #ccc;
  337. border-radius: 5px;
  338. margin: 20px;
  339. }
  340. </style>
  341. <template>
  342. <section>
  343. <p><span>信息管理></span>新增模板</p>
  344. <div class="content">
  345. <div class="content-item">
  346. <div class="item-title">模板组件</div>
  347. <el-row>
  348. <el-col :span="12">
  349. <div class="model" @click="addWidget(0)">
  350. <img src="../../assets/slt_small.png" alt="" />
  351. <span>单行文本</span>
  352. </div>
  353. </el-col>
  354. <el-col :span="12">
  355. <div class="model" @click="addWidget(1)">
  356. <img src="../../assets/mlt_small.png" alt="" />
  357. <span>多行文本</span>
  358. </div>
  359. </el-col>
  360. </el-row>
  361. <el-row>
  362. <el-col :span="12">
  363. <div class="model" @click="addWidget(2)">
  364. <img src="../../assets/radio_small.png" alt="" />
  365. <span>单选统计</span>
  366. </div>
  367. </el-col>
  368. <el-col :span="12">
  369. <div class="model" @click="addWidget(3)">
  370. <img src="../../assets/checked_small.png" alt="" />
  371. <span>多选统计</span>
  372. </div>
  373. </el-col>
  374. </el-row>
  375. <el-row>
  376. <el-col :span="12">
  377. <div class="model" @click="addWidget(4)">
  378. <img src="../../assets/upload_small.png" alt="" />
  379. <span>图片上传</span>
  380. </div>
  381. </el-col>
  382. <!-- <el-col :span='12'>
  383. <div class='model' @click="addWidget(5)">
  384. <img src="../../assets/file_small.png" alt="">
  385. <span>文件上传</span>
  386. </div>
  387. </el-col> -->
  388. <el-col :span="12">
  389. <div class="model" @click="addWidget(6)">
  390. <img src="../../assets/group_small.png" alt="" />
  391. <span>域组件</span>
  392. </div>
  393. </el-col>
  394. </el-row>
  395. </div>
  396. <div class="content-item middle">
  397. <div class="item-title">编辑模板-{{ title }}</div>
  398. <el-form
  399. size="small"
  400. label-width=""
  401. label-position="top"
  402. class="over_y"
  403. >
  404. <!-- handle=".dargBtn" 触发拖拽事件的按钮类名 filter=".undraggable" 不可拖拽的元素的类名 -->
  405. <vuedraggable class="wrapper" v-model="widgetList" handle=".dargBtn">
  406. <transition-group>
  407. <el-form-item
  408. v-for="(item, index) in widgetList"
  409. :key="index"
  410. :prop="item.label"
  411. :class="item.active == 1 ? 'active_item' : 'test'"
  412. @click.native.self="activeItem(index)"
  413. >
  414. <section v-if="item.type == 'input'">
  415. <el-input
  416. :readonly="item.edit"
  417. v-model="item.label"
  418. :class="[
  419. item.edit ? 'edit_label' : '',
  420. item.require ? 'require' : '',
  421. ]"
  422. ></el-input>
  423. <el-input
  424. placeholder="请输入"
  425. v-model="item.placeholder"
  426. ></el-input>
  427. <font>
  428. <el-checkbox class="item_require" v-model="item.require"
  429. >必填</el-checkbox
  430. >
  431. <span class="ctl_btn ctl_btn_note" @click="addNote(item)"
  432. >注释</span
  433. >
  434. <span
  435. class="ctl_btn ctl_btn_del"
  436. @click="widgetList.splice(index, 1)"
  437. >删除</span
  438. >
  439. </font>
  440. <el-button type="primary" class="dargBtn drag" size="mini"
  441. >拖拽移动顺序</el-button
  442. >
  443. </section>
  444. <section v-if="item.type == 'textarea'">
  445. <el-input
  446. :readonly="item.edit"
  447. v-model="item.label"
  448. :class="[
  449. item.edit ? 'edit_label' : '',
  450. item.require ? 'require' : '',
  451. ]"
  452. ></el-input>
  453. <el-input
  454. type="textarea"
  455. placeholder="请输入"
  456. v-model="item.placeholder"
  457. ></el-input>
  458. <font>
  459. <el-checkbox class="item_require" v-model="item.require"
  460. >必填</el-checkbox
  461. >
  462. <span class="ctl_btn ctl_btn_note" @click="addNote(item)"
  463. >注释</span
  464. >
  465. <span
  466. @click="widgetList.splice(index, 1)"
  467. class="ctl_btn ctl_btn_del"
  468. >删除</span
  469. >
  470. </font>
  471. <el-button type="primary" class="dargBtn drag" size="mini"
  472. >拖拽移动顺序</el-button
  473. >
  474. </section>
  475. <section v-if="item.type == 'radio'" class="radio">
  476. <el-input
  477. :readonly="item.edit"
  478. v-model="item.label"
  479. :class="[
  480. item.edit ? 'edit_label' : '',
  481. item.require ? 'require' : '',
  482. ]"
  483. ></el-input
  484. >(单选)
  485. <el-radio-group>
  486. <el-radio
  487. :label="iitem.label"
  488. v-for="(iitem, index) in item.items"
  489. :key="'r' + index"
  490. >
  491. <el-input
  492. :readonly="item.edit"
  493. v-model="iitem.label"
  494. :class="item.edit ? 'edit_label' : ''"
  495. ></el-input>
  496. <template v-if="!item.edit">
  497. <i
  498. class="el-icon-minus opicon"
  499. @click="minusOption(item.items, index)"
  500. ></i
  501. ><i
  502. class="el-icon-plus opicon"
  503. @click="plusOption(item.items, index)"
  504. ></i>
  505. </template>
  506. </el-radio>
  507. </el-radio-group>
  508. <font>
  509. <el-checkbox class="item_require" v-model="item.require"
  510. >必填</el-checkbox
  511. >
  512. <span class="ctl_btn ctl_btn_note" @click="addNote(item)"
  513. >注释</span
  514. >
  515. <span
  516. class="ctl_btn ctl_btn_change"
  517. @click="item.type = 'checkbox',item.cntype='(多选)'"
  518. >切换成多选</span
  519. >
  520. <span
  521. @click="widgetList.splice(index, 1)"
  522. class="ctl_btn ctl_btn_del"
  523. >删除</span
  524. >
  525. </font>
  526. <el-button type="primary" class="dargBtn drag" size="mini"
  527. >拖拽移动顺序</el-button
  528. >
  529. </section>
  530. <section v-if="item.type == 'checkbox'" class="checkbox">
  531. <el-input
  532. :readonly="item.edit"
  533. v-model="item.label"
  534. :class="[
  535. item.edit ? 'edit_label' : '',
  536. item.require ? 'require' : '',
  537. ]"
  538. ></el-input
  539. >(多选)
  540. <el-radio-group>
  541. <el-checkbox
  542. :label="iitem.label"
  543. v-for="(iitem, index) in item.items"
  544. :key="'c' + index"
  545. >
  546. <el-input
  547. :readonly="item.edit"
  548. v-model="iitem.label"
  549. :class="item.edit ? 'edit_label' : ''"
  550. ></el-input>
  551. <template v-if="!item.edit">
  552. <i
  553. class="el-icon-minus opicon"
  554. @click="minusOption(item.items, index)"
  555. ></i
  556. ><i
  557. class="el-icon-plus opicon"
  558. @click="plusOption(item.items, index)"
  559. ></i>
  560. </template>
  561. </el-checkbox>
  562. </el-radio-group>
  563. <font>
  564. <el-checkbox class="item_require" v-model="item.require"
  565. >必填</el-checkbox
  566. >
  567. <span class="ctl_btn ctl_btn_note" @click="addNote(item)"
  568. >注释</span
  569. >
  570. <span
  571. class="ctl_btn ctl_btn_change"
  572. @click="item.type = 'radio',item.cntype='(单选)'"
  573. >切换成单选</span
  574. >
  575. <span
  576. @click="widgetList.splice(index, 1)"
  577. class="ctl_btn ctl_btn_del"
  578. >删除</span
  579. >
  580. </font>
  581. <el-button type="primary" class="dargBtn drag" size="mini"
  582. >拖拽移动顺序</el-button
  583. >
  584. </section>
  585. <section v-if="item.type == 'image'">
  586. <!-- <el-input :readonly="item.edit" v-model="item.label" :class="item.edit?'edit_label':''"></el-input> -->
  587. <el-input
  588. :readonly="item.edit"
  589. v-model="item.label"
  590. :class="[
  591. item.edit ? 'edit_label' : '',
  592. item.require ? 'require' : '',
  593. ]"
  594. ></el-input>
  595. <el-upload
  596. action="/api/admin/uploadfile"
  597. list-type="picture-card"
  598. :on-preview="handlePreview"
  599. :on-remove="handleRemove"
  600. :limit="9"
  601. >
  602. <i class="el-icon-plus"></i>
  603. </el-upload>
  604. <font>
  605. <el-checkbox class="item_require" v-model="item.require"
  606. >必填</el-checkbox
  607. >
  608. <span class="ctl_btn ctl_btn_note" @click="addNote(item)"
  609. >注释</span
  610. >
  611. <span
  612. @click="widgetList.splice(index, 1)"
  613. class="ctl_btn ctl_btn_del"
  614. >删除</span
  615. >
  616. </font>
  617. <el-button type="primary" class="dargBtn drag" size="mini"
  618. >拖拽移动顺序</el-button
  619. >
  620. </section>
  621. <section v-if="item.type == 'file'">
  622. <el-input
  623. :readonly="item.edit"
  624. v-model="item.label"
  625. :class="item.edit ? 'edit_label' : ''"
  626. ></el-input>
  627. <el-upload
  628. class="upload-demo"
  629. ref="upload"
  630. action="/api/admin/uploadfile"
  631. :on-preview="handlePreview"
  632. :on-remove="handleRemove"
  633. :file-list="fileList"
  634. :auto-upload="false"
  635. >
  636. <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
  637. <el-button
  638. style="margin-left: 10px"
  639. size="small"
  640. type="primary"
  641. plain
  642. @click="submitUpload"
  643. >添加文件</el-button
  644. >
  645. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  646. </el-upload>
  647. <font>
  648. <span @click="widgetList.splice(index, 1)">删除</span>
  649. </font>
  650. <el-button type="primary" class="dargBtn drag" size="mini"
  651. >拖拽移动顺序</el-button
  652. >
  653. </section>
  654. <!-- 域组件 -->
  655. <section v-if="item.type == 'group'" class="group">
  656. <el-input
  657. :readonly="item.edit"
  658. v-model="item.label"
  659. :class="[
  660. item.edit ? 'edit_label' : '',
  661. item.require ? 'require' : '',
  662. ]"
  663. ></el-input>
  664. <vuedraggable
  665. class="wrapper"
  666. v-model="item.children"
  667. handle=".gdrag"
  668. >
  669. <transition-group>
  670. <el-form-item
  671. v-for="(iitem, index) in item.children"
  672. :key="'g' + index"
  673. :prop="iitem.label"
  674. >
  675. <section v-if="iitem.type == 'input'">
  676. <el-input
  677. :readonly="iitem.edit"
  678. v-model="iitem.label"
  679. :class="[
  680. iitem.edit ? 'edit_label' : '',
  681. iitem.require ? 'require' : '',
  682. ]"
  683. ></el-input>
  684. <el-input
  685. placeholder="请输入"
  686. v-model="iitem.placeholder"
  687. ></el-input>
  688. <font>
  689. <el-checkbox
  690. class="item_require"
  691. v-model="iitem.require"
  692. >必填</el-checkbox
  693. >
  694. <span
  695. class="ctl_btn ctl_btn_note"
  696. @click="addNote(iitem)"
  697. >注释</span
  698. >
  699. <span
  700. class="ctl_btn ctl_btn_del"
  701. @click="item.children.splice(index, 1)"
  702. >删除</span
  703. >
  704. </font>
  705. <el-button
  706. type="primary"
  707. class="gdrag drag"
  708. size="mini"
  709. >排序</el-button
  710. >
  711. </section>
  712. <section v-if="iitem.type == 'textarea'">
  713. <el-input
  714. :readonly="iitem.edit"
  715. v-model="iitem.label"
  716. :class="[
  717. iitem.edit ? 'edit_label' : '',
  718. iitem.require ? 'require' : '',
  719. ]"
  720. ></el-input>
  721. <el-input
  722. type="textarea"
  723. placeholder="请输入"
  724. v-model="iitem.placeholder"
  725. ></el-input>
  726. <font>
  727. <el-checkbox
  728. class="item_require"
  729. v-model="iitem.require"
  730. >必填</el-checkbox
  731. >
  732. <span
  733. class="ctl_btn ctl_btn_note"
  734. @click="addNote(iitem)"
  735. >注释</span
  736. >
  737. <span
  738. class="ctl_btn ctl_btn_del"
  739. @click="item.children.splice(index, 1)"
  740. >删除</span
  741. >
  742. </font>
  743. <el-button
  744. type="primary"
  745. class="gdrag drag"
  746. size="mini"
  747. >排序</el-button
  748. >
  749. </section>
  750. <section v-if="iitem.type == 'radio'" class="radio">
  751. <el-input
  752. :readonly="iitem.edit"
  753. v-model="iitem.label"
  754. :class="[
  755. iitem.edit ? 'edit_label' : '',
  756. iitem.require ? 'require' : '',
  757. ]"
  758. ></el-input
  759. >(单选)
  760. <el-radio-group>
  761. <el-radio
  762. :label="iiitem.label"
  763. v-for="(iiitem, rindex) in iitem.items"
  764. :key="'gr' + rindex"
  765. >
  766. <el-input
  767. :readonly="iitem.edit"
  768. v-model="iiitem.label"
  769. :class="iitem.edit ? 'edit_label' : ''"
  770. ></el-input>
  771. <template v-if="!iitem.edit">
  772. <i
  773. class="el-icon-minus opicon"
  774. @click="minusOption(iitem.items, index)"
  775. ></i
  776. ><i
  777. class="el-icon-plus opicon"
  778. @click="plusOption(iitem.items, index)"
  779. ></i>
  780. </template>
  781. </el-radio>
  782. </el-radio-group>
  783. <font>
  784. <el-checkbox
  785. class="item_require"
  786. v-model="iitem.require"
  787. >必填</el-checkbox
  788. >
  789. <span
  790. class="ctl_btn ctl_btn_note"
  791. @click="addNote(iitem)"
  792. >注释</span
  793. >
  794. <span
  795. class="ctl_btn ctl_btn_change"
  796. @click="iitem.type = 'checkbox',item.cntype='(多选)'"
  797. >切换成多选</span
  798. >
  799. <span
  800. @click="item.children.splice(index, 1)"
  801. class="ctl_btn ctl_btn_del"
  802. >删除</span
  803. >
  804. </font>
  805. <el-button
  806. type="primary"
  807. class="gdrag drag"
  808. size="mini"
  809. >排序</el-button
  810. >
  811. </section>
  812. <section
  813. v-if="iitem.type == 'checkbox'"
  814. class="checkbox"
  815. >
  816. <el-input
  817. :readonly="iitem.edit"
  818. v-model="iitem.label"
  819. :class="[
  820. iitem.edit ? 'edit_label' : '',
  821. iitem.require ? 'require' : '',
  822. ]"
  823. ></el-input
  824. >(多选)
  825. <el-radio-group>
  826. <el-checkbox
  827. :label="iiitem.label"
  828. v-for="(iiitem, index) in iitem.items"
  829. :key="'gc' + index"
  830. >
  831. <el-input
  832. :readonly="iitem.edit"
  833. v-model="iiitem.label"
  834. :class="iitem.edit ? 'edit_label' : ''"
  835. ></el-input>
  836. <template v-if="!iitem.edit">
  837. <i
  838. class="el-icon-minus opicon"
  839. @click="minusOption(iitem.items, index)"
  840. ></i
  841. ><i
  842. class="el-icon-plus opicon"
  843. @click="plusOption(iitem.items, index)"
  844. ></i>
  845. </template>
  846. </el-checkbox>
  847. </el-radio-group>
  848. <font>
  849. <el-checkbox
  850. class="item_require"
  851. v-model="iitem.require"
  852. >必填</el-checkbox
  853. >
  854. <span
  855. class="ctl_btn ctl_btn_note"
  856. @click="addNote(iitem)"
  857. >注释</span
  858. >
  859. <span
  860. class="ctl_btn ctl_btn_change"
  861. @click="iitem.type = 'radio',item.cntype='(单选)'"
  862. >切换成多选</span
  863. >
  864. <span
  865. @click="item.children.splice(index, 1)"
  866. class="ctl_btn ctl_btn_del"
  867. >删除</span
  868. >
  869. </font>
  870. <el-button
  871. type="primary"
  872. class="gdrag drag"
  873. size="mini"
  874. >排序</el-button
  875. >
  876. </section>
  877. <section v-if="iitem.type == 'image'">
  878. <!-- <el-input :readonly="item.edit" v-model="item.label" :class="item.edit?'edit_label':''"></el-input> -->
  879. <el-input
  880. :readonly="iitem.edit"
  881. v-model="iitem.label"
  882. :class="[
  883. iitem.edit ? 'edit_label' : '',
  884. iitem.require ? 'require' : '',
  885. ]"
  886. ></el-input>
  887. <el-upload
  888. action="/api/admin/uploadfile"
  889. list-type="picture-card"
  890. :on-preview="handlePreview"
  891. :on-remove="handleRemove"
  892. :limit="9"
  893. >
  894. <i class="el-icon-plus"></i>
  895. </el-upload>
  896. <font>
  897. <el-checkbox
  898. class="item_require"
  899. v-model="iitem.require"
  900. >必填</el-checkbox
  901. >
  902. <span
  903. class="ctl_btn ctl_btn_note"
  904. @click="addNote(iitem)"
  905. >注释</span
  906. >
  907. <span
  908. @click="item.children.splice(index, 1)"
  909. class="ctl_btn ctl_btn_del"
  910. >删除</span
  911. >
  912. </font>
  913. <el-button
  914. type="primary"
  915. class="gdrag drag"
  916. size="mini"
  917. >排序</el-button
  918. >
  919. </section>
  920. </el-form-item>
  921. </transition-group>
  922. </vuedraggable>
  923. </section>
  924. <font style="top: -18px" v-if="item.type == 'group'">
  925. <span @click="widgetList.splice(index, 1)">删除</span>
  926. </font>
  927. <el-button type="primary" class="dargBtn drag" size="mini"
  928. >拖拽移动顺序</el-button
  929. >
  930. </el-form-item>
  931. </transition-group>
  932. </vuedraggable>
  933. <div v-if="this.widgetList.length">
  934. <el-button size="medium" type="primary" @click="save"
  935. >保存</el-button
  936. >
  937. </div>
  938. </el-form>
  939. <!-- 添加注释 -->
  940. <el-dialog
  941. class="noteDialog"
  942. :title="dialogTitle"
  943. :close-on-click-modal="false"
  944. :visible.sync="dialogVisible"
  945. >
  946. <el-form
  947. size="small"
  948. class="preview"
  949. :inline="false"
  950. label-width="80px"
  951. ref="form1"
  952. :rules="rules"
  953. >
  954. <el-form-item>
  955. <el-input
  956. v-model="noteDesc"
  957. placeholder="请输入注释信息"
  958. ></el-input>
  959. </el-form-item>
  960. <el-form-item>
  961. <ul class="img_list">
  962. <li v-for="(item, index) in noteImgs" :key="'note' + index">
  963. <img :src="item" alt="" />
  964. <p class="move">
  965. <i @click="remove(index)" class="el-icon-delete"></i>
  966. </p>
  967. </li>
  968. <li>
  969. <el-upload
  970. multiple
  971. :on-success="imgchange"
  972. action="/api/admin/uploadfile"
  973. :show-file-list="false"
  974. list-type="picture-card"
  975. :limit="9"
  976. :on-exceed="limitUploadNum"
  977. :file-list="fileList"
  978. >
  979. <i class="el-icon-plus"></i>
  980. </el-upload>
  981. </li>
  982. </ul>
  983. </el-form-item>
  984. </el-form>
  985. <span slot="footer" class="dialog-footer">
  986. <el-button
  987. size="small"
  988. type="normal"
  989. @click="(dialogVisible = false), (curNote = '<p></p>')"
  990. >取消</el-button
  991. >
  992. <el-button size="small" type="primary" @click="saveNote(curItem)"
  993. >确 定</el-button
  994. >
  995. </span>
  996. </el-dialog>
  997. </div>
  998. <div class="content-item right">
  999. <div class="item-title">效果预览</div>
  1000. <div class="phone">
  1001. <div class="item-main" style="position: relative">
  1002. <!-- <img src="../../assets/survey_logo.png" alt="" class="survey_logo"> -->
  1003. <h5 align="center" class="tpl_title">{{ title }}</h5>
  1004. <el-form ref="form" :model="form" class="tpl_form over_y">
  1005. <template v-for="(item, index) in widgetList">
  1006. <el-form-item
  1007. v-show="item.type != 'group'"
  1008. :key="'review' + index"
  1009. :label="item.label + item.cntype"
  1010. >
  1011. <span style="color: #409eff; font-size: 12px">{{
  1012. item.noteDesc
  1013. }}</span>
  1014. <el-tooltip
  1015. class="item"
  1016. effect="dark"
  1017. content="Left Bottom 提示文字"
  1018. placement="bottom-end"
  1019. >
  1020. <i
  1021. v-show="item.noteDesc || item.noteImgs"
  1022. class="el-icon-info"
  1023. style="position: absolute; top: -28px; right: 0px"
  1024. ></i>
  1025. <div slot="content" class="tool_text">
  1026. <p>{{ item.noteDesc }}</p>
  1027. <div class="toolText_img">
  1028. <!-- <img
  1029. :src="item"
  1030. alt=""
  1031. v-for="(item, index) in item.noteImgs"
  1032. :key="'noteimgs'+index"
  1033. /> -->
  1034. </div>
  1035. </div>
  1036. </el-tooltip>
  1037. <el-input
  1038. :class="item.require ? 'require' : ''"
  1039. v-if="item.type == 'input'"
  1040. v-model="form.label"
  1041. :placeholder="item.placeholder"
  1042. ></el-input>
  1043. <el-input
  1044. :class="item.require ? 'require' : ''"
  1045. v-if="item.type == 'textarea'"
  1046. type="textarea"
  1047. v-model="form.label"
  1048. :placeholder="item.placeholder"
  1049. ></el-input>
  1050. <el-radio-group
  1051. class="cus_select"
  1052. v-if="item.type == 'radio'"
  1053. :class="item.require ? 'require' : ''"
  1054. >
  1055. <el-radio
  1056. :label="iitem.label"
  1057. v-for="(iitem, index) in item.items"
  1058. :key="'review_r' + index"
  1059. >{{ iitem.label }}</el-radio
  1060. >
  1061. </el-radio-group>
  1062. <el-radio-group
  1063. class="cus_select"
  1064. v-if="item.type == 'checkbox'"
  1065. :class="item.require ? 'require' : ''"
  1066. >
  1067. <el-checkbox
  1068. :label="iitem.label"
  1069. v-for="(iitem, index) in item.items"
  1070. :key="'review_c' + index"
  1071. >{{ iitem.label }}</el-checkbox
  1072. >
  1073. </el-radio-group>
  1074. <el-upload
  1075. :class="item.require ? 'require' : ''"
  1076. v-if="item.type == 'image'"
  1077. action="/api/admin/uploadfile"
  1078. list-type="picture-card"
  1079. :on-preview="handlePreview"
  1080. :on-remove="handleRemove"
  1081. >
  1082. <i class="el-icon-plus"></i>
  1083. </el-upload>
  1084. <el-upload
  1085. v-if="item.type == 'file'"
  1086. class="upload-demo"
  1087. ref="upload"
  1088. action="/api/admin/uploadfile"
  1089. :on-preview="handlePreview"
  1090. :on-remove="handleRemove"
  1091. :file-list="fileList"
  1092. :auto-upload="false"
  1093. >
  1094. <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
  1095. <el-button
  1096. style="margin-left: 10px"
  1097. size="small"
  1098. type="primary"
  1099. plain
  1100. @click="submitUpload"
  1101. >添加文件</el-button
  1102. >
  1103. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  1104. </el-upload>
  1105. </el-form-item>
  1106. <!-- 域组件展示 -->
  1107. <section
  1108. class="groupMain"
  1109. v-if="item.type == 'group'"
  1110. :key="'review_gi' + index"
  1111. >
  1112. <h6
  1113. v-if="item.type == 'group'"
  1114. align="left"
  1115. class="group_title"
  1116. :key="'revire_g' + index"
  1117. >
  1118. {{ item.label }}
  1119. </h6>
  1120. <template v-for="(iitem, index) in item.children">
  1121. <el-form-item
  1122. :key="'review_gc' + index"
  1123. :label="iitem.label + iitem.cntype"
  1124. >
  1125. <span style="color: #409eff; font-size: 12px">{{
  1126. iitem.noteDesc
  1127. }}</span>
  1128. <el-tooltip
  1129. class="item"
  1130. effect="dark"
  1131. content="Left Bottom 提示文字"
  1132. placement="bottom-end"
  1133. >
  1134. <i
  1135. v-if="iitem.noteDesc || iitem.noteImgs"
  1136. class="el-icon-info"
  1137. style="position: absolute; top: -28px; right: 0px"
  1138. ></i>
  1139. <div slot="content" class="tool_text">
  1140. <p>{{ iitem.noteDesc }}</p>
  1141. <div class="toolText_img">
  1142. <img
  1143. :src="iitem"
  1144. alt=""
  1145. v-for="(iitem, index) in iitem.noteImgs"
  1146. :key="'review_gc_noteimgs' + index"
  1147. />
  1148. </div>
  1149. </div>
  1150. </el-tooltip>
  1151. <el-input
  1152. :class="iitem.require ? 'require' : ''"
  1153. v-if="iitem.type == 'input'"
  1154. v-model="form.label"
  1155. :placeholder="iitem.placeholder"
  1156. ></el-input>
  1157. <el-input
  1158. :class="iitem.require ? 'require' : ''"
  1159. v-if="iitem.type == 'textarea'"
  1160. type="textarea"
  1161. v-model="form.label"
  1162. :placeholder="iitem.placeholder"
  1163. ></el-input>
  1164. <el-radio-group
  1165. class="cus_select"
  1166. v-if="iitem.type == 'radio'"
  1167. :class="iitem.require ? 'require' : ''"
  1168. >
  1169. <el-radio
  1170. :label="iiitem.label"
  1171. v-for="(iiitem, index) in iitem.items"
  1172. :key="'review_gcr' + index"
  1173. >{{ iiitem.label }}</el-radio
  1174. >
  1175. </el-radio-group>
  1176. <el-radio-group
  1177. class="cus_select"
  1178. v-if="iitem.type == 'checkbox'"
  1179. :class="iitem.require ? 'require' : ''"
  1180. >
  1181. <el-checkbox
  1182. :label="iiitem.label"
  1183. v-for="(iiitem, index) in iitem.items"
  1184. :key="'review_gcc' + index"
  1185. >{{ iiitem.label }}</el-checkbox
  1186. >
  1187. </el-radio-group>
  1188. <el-upload
  1189. :class="iitem.require ? 'require' : ''"
  1190. v-if="iitem.type == 'image'"
  1191. action="/api/admin/uploadfile"
  1192. list-type="picture-card"
  1193. :on-preview="handlePreview"
  1194. :on-remove="handleRemove"
  1195. >
  1196. <i class="el-icon-plus"></i>
  1197. </el-upload>
  1198. <el-upload
  1199. v-if="iitem.type == 'file'"
  1200. class="upload-demo"
  1201. ref="upload"
  1202. action="/api/admin/uploadfile"
  1203. :on-preview="handlePreview"
  1204. :on-remove="handleRemove"
  1205. :file-list="fileList"
  1206. :auto-upload="false"
  1207. >
  1208. <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
  1209. <el-button
  1210. style="margin-left: 10px"
  1211. size="small"
  1212. type="primary"
  1213. plain
  1214. @click="submitUpload"
  1215. >添加文件</el-button
  1216. >
  1217. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  1218. </el-upload>
  1219. </el-form-item>
  1220. </template>
  1221. </section>
  1222. <!-- 域组件end -->
  1223. </template>
  1224. <el-form-item v-if="this.widgetList.length">
  1225. <el-button
  1226. size="medium"
  1227. type="primary"
  1228. @click="dialogVisible = false"
  1229. style="width: 100%; margin-top: 20px"
  1230. >提交</el-button
  1231. >
  1232. </el-form-item>
  1233. </el-form>
  1234. <!-- 展示注释信息 -->
  1235. <!-- <div class="noteInfoDialog">
  1236. <div class="body">
  1237. <el-button size="mini">关闭</el-button>
  1238. </div>
  1239. </div> -->
  1240. </div>
  1241. </div>
  1242. <!-- 注释信息展示 -->
  1243. <el-dialog
  1244. class="noteDialog"
  1245. :title="dialogTitle1"
  1246. :close-on-click-modal="false"
  1247. :visible.sync="dialogVisible1"
  1248. >
  1249. <span slot="footer" class="dialog-footer">
  1250. <el-button
  1251. size="small"
  1252. type="normal"
  1253. @click="
  1254. (dialogVisible = false), (noteForm = {}), (curNote = '<p></p>')
  1255. "
  1256. >取消</el-button
  1257. >
  1258. <el-button size="small" type="primary" @click="saveNote(curItem)"
  1259. >确 定</el-button
  1260. >
  1261. </span>
  1262. </el-dialog>
  1263. </div>
  1264. </div>
  1265. </section>
  1266. </template>
  1267. <script>
  1268. import vuedraggable from "vuedraggable";
  1269. import fuEditor from "../../components/fuEditor";
  1270. export default {
  1271. components: { vuedraggable, fuEditor },
  1272. data() {
  1273. return {
  1274. fileList: [],
  1275. noteDesc: "",
  1276. noteImgs: [],
  1277. realImgs: [],
  1278. noteImgList: [],
  1279. curItem: {},
  1280. dialogTitle: "",
  1281. dialogTitle1: "",
  1282. // noteForm:{noteDesc:"",noteImgs:[]},
  1283. curNote: "",
  1284. dialogVisible: false,
  1285. dialogVisible1: false,
  1286. rules: {
  1287. 姓名: [{ required: true, message: "请输入标题", trigger: "blur" }],
  1288. },
  1289. title: this.$route.query.title,
  1290. edit: 0,
  1291. form: { name: "", page: 1, page_size: 20 },
  1292. total: 1,
  1293. list: [{ name: "2333" }],
  1294. loading: false,
  1295. checkList: [],
  1296. input: "",
  1297. dialogVisible: false,
  1298. defaultProps: {},
  1299. data: [
  1300. {
  1301. id: 1,
  1302. label: "一级 1",
  1303. },
  1304. {
  1305. id: 2,
  1306. label: "一级 2",
  1307. children: [
  1308. {
  1309. id: 5,
  1310. label: "二级 2-1",
  1311. },
  1312. {
  1313. id: 6,
  1314. label: "二级 2-2",
  1315. },
  1316. ],
  1317. },
  1318. ],
  1319. stdWidgetList: [
  1320. {
  1321. type: "input",
  1322. cntype: "",
  1323. label: "请输入标题",
  1324. placeholder: "请输入",
  1325. edit: false,
  1326. require: true,
  1327. },
  1328. {
  1329. type: "textarea",
  1330. cntype: "",
  1331. label: "请输入标题",
  1332. placeholder: "请输入",
  1333. edit: false,
  1334. require: true,
  1335. },
  1336. {
  1337. type: "radio",
  1338. cntype: "(单选)",
  1339. label: "请输入标题",
  1340. placeholder: "请输入",
  1341. edit: false,
  1342. require: true,
  1343. items: [
  1344. { label: "选项", value: "选项值" },
  1345. { label: "选项1", value: "选项值" },
  1346. ],
  1347. },
  1348. {
  1349. type: "checkbox",
  1350. cntype: "(多选)",
  1351. label: "请输入标题",
  1352. placeholder: "请输入",
  1353. edit: false,
  1354. require: true,
  1355. items: [
  1356. { label: "选项", value: "选项值" },
  1357. { label: "选项1", value: "选项值" },
  1358. ],
  1359. },
  1360. {
  1361. type: "image",
  1362. cntype: "",
  1363. label: "请输入标题",
  1364. placeholder: "请输入",
  1365. edit: false,
  1366. require: true,
  1367. },
  1368. {
  1369. type: "file",
  1370. cntype: "",
  1371. label: "请输入标题",
  1372. placeholder: "请输入",
  1373. edit: false,
  1374. require: true,
  1375. },
  1376. {
  1377. type: "group",
  1378. cntype: "",
  1379. label: "域组件",
  1380. placeholder: "请输入",
  1381. edit: false,
  1382. require: true,
  1383. children: [],
  1384. },
  1385. ],
  1386. widgetList: [],
  1387. };
  1388. },
  1389. methods: {
  1390. limitUploadNum(files, fileList) {
  1391. this.$message.alert("最多只能上传9张图片!");
  1392. },
  1393. showNoteInfo() {
  1394. // this.dialogTitle1 = true
  1395. // this.dialogVisible1 = true;
  1396. },
  1397. activeItem(index) {
  1398. var widgetList = this.widgetList;
  1399. for (let i = 0; i < widgetList.length; i++) {
  1400. if (widgetList[i].type == "group") {
  1401. if (i == index) {
  1402. this.$set(widgetList[i], "active", !widgetList[i].active);
  1403. } else {
  1404. this.$set(widgetList[i], "active", 0);
  1405. }
  1406. // this.$set(widgetList[i], "active", !widgetList[i].active);
  1407. }
  1408. }
  1409. this.widgetList = widgetList;
  1410. },
  1411. change(evt) {},
  1412. start(evt) {},
  1413. end(evt) {},
  1414. upload() {},
  1415. imgchange(file, fileList) {
  1416. var img = this.noteImgs;
  1417. if (img.length > 8) {
  1418. this.$message.error("最多只能上传9张图片!");
  1419. return;
  1420. }
  1421. img.push(fileList.response.data);
  1422. this.noteImgs = img;
  1423. },
  1424. remove(index) {
  1425. var img = this.noteImgs;
  1426. img.splice(index, 1);
  1427. this.noteImgs = img;
  1428. },
  1429. addNote(item) {
  1430. this.noteDesc = item.noteDesc;
  1431. this.noteImgs = item.noteImgs ? item.noteImgs : [];
  1432. this.curItem = item;
  1433. this.dialogTitle = "为" + '"' + item.label + '"添加注释信息';
  1434. this.dialogVisible = true;
  1435. },
  1436. saveNote(item) {
  1437. debugger;
  1438. console.log(this.widgetList);
  1439. item.noteDesc = this.noteDesc;
  1440. item.noteImgs = this.noteImgs;
  1441. this.curItem = item;
  1442. this.dialogVisible = false;
  1443. },
  1444. handlePreview() {},
  1445. handleRemove() {},
  1446. unique(arr) {
  1447. var x = new Set(arr);
  1448. return [...x];
  1449. },
  1450. save() {
  1451. let id = this.$route.query.id;
  1452. let copyid = this.$route.query.copyid;
  1453. let widgets = Array.from(this.widgetList);
  1454. let flag = 0;
  1455. let labels = [];
  1456. widgets.forEach((item, index) => {
  1457. labels.push(item.label);
  1458. });
  1459. if (labels.length != this.unique(labels).length) {
  1460. flag = 1;
  1461. this.$alert("题干不能相同请仔细检查数据!", "数据错误", {
  1462. confirmButtonText: "确定",
  1463. type: "error",
  1464. });
  1465. return false;
  1466. }
  1467. widgets.forEach((item, index) => {
  1468. if (item.label == "") {
  1469. flag = 2;
  1470. }
  1471. if (item.type == "radio" || item.type == "checkbox") {
  1472. let item_labels = [];
  1473. item.items.forEach((obj, index) => {
  1474. item_labels.push(obj.label);
  1475. });
  1476. if (item_labels.length != this.unique(item_labels).length) {
  1477. flag = 3;
  1478. }
  1479. }
  1480. });
  1481. if (flag == 2) {
  1482. this.$alert("题干不能为空请仔细检查数据!", "数据错误", {
  1483. confirmButtonText: "确定",
  1484. type: "error",
  1485. });
  1486. return false;
  1487. }
  1488. if (flag == 3) {
  1489. this.$alert("选择题选项不能相同请仔细检查数据!", "数据错误", {
  1490. confirmButtonText: "确定",
  1491. type: "error",
  1492. });
  1493. return false;
  1494. }
  1495. let params = {
  1496. name: this.title,
  1497. widget: JSON.stringify(widgets),
  1498. };
  1499. if (id && !copyid) {
  1500. params.id = id;
  1501. this.$api.editTemplate(params).then((res) => {
  1502. if (res.data.code == 0) {
  1503. this.$message({
  1504. type: "success",
  1505. message: "成功!",
  1506. });
  1507. } else {
  1508. this.$message.error("失败!");
  1509. }
  1510. this.$router.push("/message/template");
  1511. });
  1512. } else {
  1513. this.$api.addTemplate(params).then((res) => {
  1514. if (res.data.code == 0) {
  1515. this.$message({
  1516. type: "success",
  1517. message: "成功!",
  1518. });
  1519. } else {
  1520. this.$message.error("失败!");
  1521. }
  1522. this.$router.push("/message/template");
  1523. });
  1524. }
  1525. },
  1526. addWidget(i) {
  1527. let item = JSON.parse(JSON.stringify(this.stdWidgetList[i]));
  1528. if (item.type == "group") {
  1529. item.active = 1;
  1530. this.widgetList.forEach((item, index) => {
  1531. item.active = 0;
  1532. });
  1533. }
  1534. // 筛选域组件
  1535. let gwidget = this.widgetList.filter(function (val) {
  1536. return val.type == "group" && val.active == 1;
  1537. });
  1538. if (gwidget.length) {
  1539. item.label = item.label + (gwidget[0].children.length + 1).toString();
  1540. gwidget[0].children.push(item);
  1541. } else {
  1542. item.label = item.label + (this.widgetList.length + 1).toString();
  1543. this.widgetList.push(item);
  1544. }
  1545. },
  1546. minusOption(options, index) {
  1547. if (options.length <= 1) {
  1548. this.$message.error("选项不能少于1个!");
  1549. } else {
  1550. options.splice(index, 1);
  1551. }
  1552. },
  1553. plusOption(options, index) {
  1554. if (options.length >= 100) {
  1555. this.$message.error("选项不能超过100个!");
  1556. } else {
  1557. options.splice(index + 1, 0, {
  1558. label: "选项" + (index + 1),
  1559. value: "选项值",
  1560. });
  1561. }
  1562. },
  1563. gopage(size) {
  1564. if (size) {
  1565. this.form.page_size = size;
  1566. }
  1567. this.form.page = this.$refs.pageButton.page;
  1568. this.getData();
  1569. },
  1570. handleSelectionChange(val) {
  1571. this.multipleSelection = val;
  1572. },
  1573. gopage1(size) {
  1574. if (size) {
  1575. this.form1.page_size = size;
  1576. }
  1577. this.form1.page = this.$refs.pageButton1.page;
  1578. this.getJl();
  1579. },
  1580. open(data) {
  1581. this.dialogFormVisible = true;
  1582. this.message = { ...data };
  1583. },
  1584. download() {
  1585. let array = this.multipleSelection,
  1586. ids = [];
  1587. for (let i = 0; i < array.length; i++) {
  1588. ids.push(array[i].id);
  1589. }
  1590. ids = ids.join(",");
  1591. this.$api.downloadMon({ ids: ids }).then((res) => {
  1592. var elink = document.createElement("a");
  1593. let blob = new Blob([res.data], { type: "application/vnd.ms-excel" });
  1594. let objUrl = URL.createObjectURL(blob);
  1595. console.log(res.headers["content-disposition"]);
  1596. let file_name = res.headers["content-disposition"].split("=")[1];
  1597. elink.download = file_name;
  1598. elink.style.display = "none";
  1599. elink.href = objUrl;
  1600. document.body.appendChild(elink);
  1601. elink.click();
  1602. document.body.removeChild(elink);
  1603. });
  1604. },
  1605. prview(id) {
  1606. this.form1.enterprise_id = id;
  1607. this.getJl();
  1608. this.dialogFormVisible1 = true;
  1609. },
  1610. getJl() {
  1611. var parm = this.form1;
  1612. this.$api.getMonitjobList(parm).then((res) => {
  1613. this.data = res.data.data.list;
  1614. this.total1 = res.data.data.total;
  1615. });
  1616. },
  1617. detail(id) {
  1618. this.$router.push({
  1619. path: "/company/detail",
  1620. query: { id: id, page: this.form.page, page_size: this.form.page_size },
  1621. });
  1622. },
  1623. getData() {
  1624. let id = this.$route.query.id;
  1625. if (id) {
  1626. this.$api.getTemplate({ id: id }).then((res) => {
  1627. if (res.data.code == 0) {
  1628. this.widgetList = res.data.data.widget;
  1629. }
  1630. });
  1631. }
  1632. },
  1633. del(id) {
  1634. this.$confirm("确定删除吗?", "提示", {
  1635. type: "warning",
  1636. }).then(() => {
  1637. this.$api.deleteEnterprise({ id: id }).then((res) => {
  1638. this.$message({
  1639. message: "删除成功",
  1640. type: "success",
  1641. });
  1642. this.getData();
  1643. });
  1644. });
  1645. },
  1646. permission(name) {
  1647. let permissions = this.info.permissions || [];
  1648. let list = [];
  1649. for (let i = 0; i < permissions.length; i++) {
  1650. list.push(permissions[i].name);
  1651. }
  1652. if (list.indexOf(name) < 0) {
  1653. return false;
  1654. } else {
  1655. return true;
  1656. }
  1657. },
  1658. },
  1659. created() {
  1660. this.getData();
  1661. },
  1662. };
  1663. </script>