modelForm.vue 56 KB

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