modelForm.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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. margin-right: 160px;
  62. position: relative;
  63. font,
  64. .drag {
  65. position: absolute;
  66. right: -145px;
  67. }
  68. font {
  69. top: 0px;
  70. color: #3895fe;
  71. font-size: 12px;
  72. span {
  73. margin-left: 5px;
  74. cursor: pointer;
  75. }
  76. }
  77. .drag {
  78. right: -160px;
  79. bottom: -3px;
  80. }
  81. div {
  82. font-size: 16px;
  83. color: #333333;
  84. }
  85. .el-radio,
  86. .el-checkbox {
  87. margin-right: 32px;
  88. // height: 32px;
  89. line-height: 20px;
  90. }
  91. .el-radio-group,
  92. .el-checkbox-group {
  93. display: flex;
  94. flex-direction: column;
  95. }
  96. .cus_select .el-radio,
  97. .el-radio__input {
  98. white-space: normal;
  99. }
  100. .cus_select .el-checkbox,
  101. .el-checkbox__input {
  102. white-space: normal;
  103. }
  104. .cus_select .el-checkbox__label {
  105. display: inline;
  106. }
  107. .el-radio__label,
  108. .el-checkbox__label {
  109. display: inline-block !important;
  110. width: 93%;
  111. vertical-align: top;
  112. }
  113. .el-radio,
  114. .el-checkbox {
  115. margin-bottom: 10px;
  116. }
  117. }
  118. /deep/.el-form-item__label {
  119. float: none;
  120. font-weight: bold;
  121. }
  122. &.text {
  123. /deep/.el-form-item__content {
  124. // margin-left:60px;
  125. }
  126. }
  127. }
  128. }
  129. // 右边
  130. .phone {
  131. width: 350px;
  132. height: 713px;
  133. background: url("../../assets/survey_bg.png") no-repeat;
  134. background-size: 100% auto;
  135. margin: auto;
  136. }
  137. .item-main {
  138. height: 551px;
  139. width: 315px;
  140. background: #ffffff;
  141. border: 1px solid #ddd;
  142. overflow: auto;
  143. position: relative;
  144. top: 80px;
  145. left: 21px;
  146. // display: none;
  147. // border: 1px solid #DDDDDD;
  148. // box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.13);
  149. border-radius: 5px;
  150. overflow: auto;
  151. .el-form.over_y {
  152. border: none;
  153. overflow: visible;
  154. }
  155. }
  156. // label样式
  157. .edit_label {
  158. /deep/.el-input__inner {
  159. background: #f5faff;
  160. border: 0px;
  161. padding: 0px;
  162. }
  163. }
  164. /deep/.opicon {
  165. font-weight: bold;
  166. padding: 5px;
  167. color: #3895fe;
  168. }
  169. .tpl_title {
  170. font-size: 18px;
  171. // margin-bottom:20px;
  172. }
  173. .tpl_form {
  174. margin: 0px;
  175. border: 1px solid #ccc;
  176. border-radius: 20px;
  177. /deep/.el-form-item {
  178. background: none;
  179. }
  180. /deep/.el-form-item__content {
  181. width: 100%;
  182. }
  183. }
  184. .survey_logo {
  185. width: 145px;
  186. position: relative;
  187. top: 5px;
  188. left: 20px;
  189. }
  190. .item_require {
  191. position: absolute;
  192. top: 0px;
  193. right: 35px !important;
  194. /deep/.el-checkbox__label {
  195. padding-left: 5px;
  196. // color:red;
  197. }
  198. }
  199. .require::before {
  200. content: "*";
  201. color: #f56c6c;
  202. margin-right: 4px;
  203. position: absolute;
  204. left: -10px;
  205. }
  206. }
  207. /deep/.radio .el-input {
  208. width: 85%;
  209. }
  210. /deep/.checkbox .el-input {
  211. width: 85%;
  212. }
  213. }
  214. </style>
  215. <template>
  216. <section>
  217. <p><span>信息管理></span>新增模板</p>
  218. <div class="content">
  219. <div class="content-item">
  220. <div class='item-title'>模板组件</div>
  221. <el-row>
  222. <el-col :span='12'>
  223. <div class='model' @click="addWidget(0)">
  224. <img src="../../assets/slt_small.png" alt="">
  225. <span>单行文本</span>
  226. </div>
  227. </el-col>
  228. <el-col :span='12'>
  229. <div class='model' @click="addWidget(1)">
  230. <img src="../../assets/mlt_small.png" alt="">
  231. <span>多行文本</span>
  232. </div>
  233. </el-col>
  234. </el-row>
  235. <el-row>
  236. <el-col :span='12'>
  237. <div class='model' @click="addWidget(2)">
  238. <img src="../../assets/radio_small.png" alt="">
  239. <span>单选统计</span>
  240. </div>
  241. </el-col>
  242. <el-col :span='12'>
  243. <div class='model' @click="addWidget(3)">
  244. <img src="../../assets/checked_small.png" alt="">
  245. <span>多选统计</span>
  246. </div>
  247. </el-col>
  248. </el-row>
  249. <!-- <el-row>
  250. <el-col :span='12'>
  251. <div class='model' @click="addWidget(4)">
  252. <img src="../../assets/upload_small.png" alt="">
  253. <span>图片上传</span>
  254. </div>
  255. </el-col>
  256. <el-col :span='12'>
  257. <div class='model' @click="addWidget(5)">
  258. <img src="../../assets/file_small.png" alt="">
  259. <span>文件上传</span>
  260. </div>
  261. </el-col>
  262. </el-row> -->
  263. </div>
  264. <div class="content-item middle">
  265. <div class='item-title'>编辑模板-{{title}}</div>
  266. <el-form size="small" label-width="" label-position="top" class='over_y'>
  267. <!-- handle=".dargBtn" 触发拖拽事件的按钮类名 filter=".undraggable" 不可拖拽的元素的类名 -->
  268. <vuedraggable class="wrapper" v-model="widgetList" handle=".dargBtn">
  269. <transition-group>
  270. <el-form-item v-for="(item,index) in widgetList" :key="index" :prop="item.label">
  271. <section v-if="item.type=='input'">
  272. <el-input :readonly="item.edit" v-model="item.label" :class="[item.edit?'edit_label':'',item.require?'require':'']"></el-input>
  273. <el-input placeholder='请输入' v-model="item.placeholder"></el-input>
  274. <font>
  275. <el-checkbox class="item_require" v-model="item.require">必填</el-checkbox>
  276. <span @click="item.edit=!item.edit">{{item.edit?'编辑':'保存'}}</span>
  277. <span @click="widgetList.splice(index,1)">删除</span>
  278. </font>
  279. <el-button type='primary' class='dargBtn drag'>拖拽移动顺序</el-button>
  280. </section>
  281. <section v-if="item.type=='textarea'">
  282. <el-input :readonly="item.edit" v-model="item.label" :class="[item.edit?'edit_label':'',item.require?'require':'']"></el-input>
  283. <el-input type="textarea" placeholder='请输入' v-model="item.placeholder"></el-input>
  284. <font>
  285. <el-checkbox class="item_require" v-model="item.require">必填</el-checkbox>
  286. <span @click="item.edit=!item.edit">{{item.edit?'编辑':'保存'}}</span>
  287. <span @click="widgetList.splice(index,1)">删除</span>
  288. </font>
  289. <el-button type='primary' class='dargBtn drag'>拖拽移动顺序</el-button>
  290. </section>
  291. <section v-if="item.type=='radio'" class="radio">
  292. <el-input :readonly="item.edit" v-model="item.label" :class="[item.edit?'edit_label':'',item.require?'require':'']"></el-input>(单选)
  293. <el-radio-group>
  294. <el-radio :label="iitem.label" v-for="(iitem,index) in item.items" :key="index">
  295. <el-input :readonly="item.edit" v-model="iitem.label" :class="item.edit?'edit_label':''"></el-input>
  296. <template v-if="!item.edit">
  297. <i class="el-icon-minus opicon" @click="minusOption(item.items,index)"></i><i class="el-icon-plus opicon" @click="plusOption(item.items,index)"></i>
  298. </template>
  299. </el-radio>
  300. </el-radio-group>
  301. <font>
  302. <el-checkbox class="item_require" v-model="item.require">必填</el-checkbox>
  303. <span @click="item.edit=!item.edit">{{item.edit?'编辑':'保存'}}</span>
  304. <span @click="widgetList.splice(index,1)">删除</span>
  305. </font>
  306. <el-button type='primary' class='dargBtn drag'>拖拽移动顺序</el-button>
  307. </section>
  308. <section v-if="item.type=='checkbox'" class="checkbox">
  309. <el-input :readonly="item.edit" v-model="item.label" :class="[item.edit?'edit_label':'',item.require?'require':'']"></el-input>(多选)
  310. <el-radio-group>
  311. <el-checkbox :label="iitem.label" v-for="(iitem,index) in item.items" :key="index">
  312. <el-input :readonly="item.edit" v-model="iitem.label" :class="item.edit?'edit_label':''"></el-input>
  313. <template v-if="!item.edit">
  314. <i class="el-icon-minus opicon" @click="minusOption(item.items,index)"></i><i class="el-icon-plus opicon" @click="plusOption(item.items,index)"></i>
  315. </template>
  316. </el-checkbox>
  317. </el-radio-group>
  318. <font>
  319. <el-checkbox class="item_require" v-model="item.require">必填</el-checkbox>
  320. <span @click="item.edit=!item.edit">{{item.edit?'编辑':'保存'}}</span>
  321. <span @click="widgetList.splice(index,1)">删除</span>
  322. </font>
  323. <el-button type='primary' class='dargBtn drag'>拖拽移动顺序</el-button>
  324. </section>
  325. <section v-if="item.type=='image'">
  326. <el-input :readonly="item.edit" v-model="item.label" :class="item.edit?'edit_label':''"></el-input>
  327. <el-upload
  328. action="https://jsonplaceholder.typicode.com/posts/"
  329. list-type="picture-card"
  330. :on-preview="handlePictureCardPreview"
  331. :on-remove="handleRemove">
  332. <i class="el-icon-plus"></i>
  333. </el-upload>
  334. <font>
  335. <span @click="item.edit=!item.edit">{{item.edit?'编辑':'保存'}}</span>
  336. <span @click="widgetList.splice(index,1)">删除</span>
  337. </font>
  338. <el-button type='primary' class='dargBtn drag'>拖拽移动顺序</el-button>
  339. </section>
  340. <section v-if="item.type=='file'">
  341. <el-input :readonly="item.edit" v-model="item.label" :class="item.edit?'edit_label':''"></el-input>
  342. <el-upload
  343. class="upload-demo"
  344. ref="upload"
  345. action="https://jsonplaceholder.typicode.com/posts/"
  346. :on-preview="handlePreview"
  347. :on-remove="handleRemove"
  348. :file-list="fileList"
  349. :auto-upload="false">
  350. <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
  351. <el-button style="margin-left: 10px;" size="small" type="primary" plain @click="submitUpload">添加文件</el-button>
  352. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  353. </el-upload>
  354. <font>
  355. <span @click="item.edit=!item.edit">{{item.edit?'编辑':'保存'}}</span>
  356. <span @click="widgetList.splice(index,1)">删除</span>
  357. </font>
  358. <el-button type='primary' class='dargBtn drag'>拖拽移动顺序</el-button>
  359. </section>
  360. </el-form-item>
  361. </transition-group>
  362. </vuedraggable>
  363. <div v-if="this.widgetList.length">
  364. <el-button size="medium" type="primary" @click="save">保存</el-button>
  365. </div>
  366. </el-form>
  367. </div>
  368. <div class="content-item right">
  369. <div class='item-title'>效果预览</div>
  370. <div class="phone">
  371. <div class='item-main'>
  372. <!-- <img src="../../assets/survey_logo.png" alt="" class="survey_logo"> -->
  373. <h5 align='center' class="tpl_title">{{title}}</h5>
  374. <el-form ref="form" :model="form" class="tpl_form over_y">
  375. <template v-for="(item,index) in widgetList">
  376. <el-form-item :key="index" :label="item.label+item.cntype">
  377. <el-input :class="item.require?'require':''" v-if="item.type=='input'" v-model="form.label" :placeholder="item.placeholder"></el-input>
  378. <el-input :class="item.require?'require':''" v-if="item.type=='textarea'" type="textarea" v-model="form.label" :placeholder="item.placeholder"></el-input>
  379. <el-radio-group class="cus_select" v-if="item.type=='radio'" :class="item.require?'require':''">
  380. <el-radio :label="iitem.label" v-for="(iitem,index) in item.items" :key="index">{{iitem.label}}</el-radio>
  381. </el-radio-group>
  382. <el-radio-group class="cus_select" v-if="item.type=='checkbox'" :class="item.require?'require':''">
  383. <el-checkbox :label="iitem.label" v-for="(iitem,index) in item.items" :key="index">{{iitem.label}}</el-checkbox>
  384. </el-radio-group>
  385. <el-upload
  386. v-if="item.type=='image'"
  387. action="https://jsonplaceholder.typicode.com/posts/"
  388. list-type="picture-card"
  389. :on-preview="handlePictureCardPreview"
  390. :on-remove="handleRemove">
  391. <i class="el-icon-plus"></i>
  392. </el-upload>
  393. <el-upload
  394. v-if="item.type=='file'"
  395. class="upload-demo"
  396. ref="upload"
  397. action="https://jsonplaceholder.typicode.com/posts/"
  398. :on-preview="handlePreview"
  399. :on-remove="handleRemove"
  400. :file-list="fileList"
  401. :auto-upload="false">
  402. <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
  403. <el-button style="margin-left: 10px;" size="small" type="primary" plain @click="submitUpload">添加文件</el-button>
  404. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  405. </el-upload>
  406. </el-form-item>
  407. </template>
  408. <el-form-item v-if="this.widgetList.length">
  409. <el-button size="medium" type="primary" @click="dialogVisible = false" style="width:100%;margin-top:20px;">提交</el-button>
  410. </el-form-item>
  411. </el-form>
  412. </div>
  413. </div>
  414. </div>
  415. </div>
  416. </section>
  417. </template>
  418. <script>
  419. import vuedraggable from "vuedraggable";
  420. export default {
  421. components: { vuedraggable },
  422. data() {
  423. return {
  424. rules: {
  425. 姓名: [{ required: true, message: "请输入标题", trigger: "blur" }],
  426. },
  427. title: this.$route.query.title,
  428. edit: 0,
  429. form: { name: "", page: 1, page_size: 20 },
  430. total: 1,
  431. list: [{ name: "2333" }],
  432. loading: false,
  433. checkList: [],
  434. input: "",
  435. dialogVisible: false,
  436. defaultProps: {},
  437. data: [
  438. {
  439. id: 1,
  440. label: "一级 1",
  441. },
  442. {
  443. id: 2,
  444. label: "一级 2",
  445. children: [
  446. {
  447. id: 5,
  448. label: "二级 2-1",
  449. },
  450. {
  451. id: 6,
  452. label: "二级 2-2",
  453. },
  454. ],
  455. },
  456. ],
  457. stdWidgetList: [
  458. {
  459. type: "input",
  460. cntype:"",
  461. label: "请输入标题",
  462. placeholder: "请输入",
  463. edit: false,
  464. require:true
  465. },
  466. {
  467. type: "textarea",
  468. cntype:"",
  469. label: "请输入标题",
  470. placeholder: "请输入",
  471. edit: false,
  472. require:true
  473. },
  474. {
  475. type: "radio",
  476. cntype:"(单选)",
  477. label: "请输入标题",
  478. placeholder: "请输入",
  479. edit: false,
  480. require:true,
  481. items: [
  482. { label: "选项", value: "选项值" },
  483. { label: "选项1", value: "选项值" },
  484. ],
  485. },
  486. {
  487. type: "checkbox",
  488. cntype:"(多选)",
  489. label: "请输入标题",
  490. placeholder: "请输入",
  491. edit: false,
  492. require:true,
  493. items: [
  494. { label: "选项", value: "选项值" },
  495. { label: "选项1", value: "选项值" },
  496. ],
  497. },
  498. {
  499. type: "image",
  500. label: "请输入标题",
  501. placeholder: "请输入",
  502. edit: true,
  503. },
  504. {
  505. type: "file",
  506. label: "请输入标题",
  507. placeholder: "请输入",
  508. edit: true,
  509. },
  510. ],
  511. widgetList: [],
  512. };
  513. },
  514. methods: {
  515. unique(arr) {
  516. var x = new Set(arr);
  517. return [...x];
  518. },
  519. save() {
  520. let id = this.$route.query.id;
  521. let copyid = this.$route.query.copyid;
  522. let widgets = Array.from(this.widgetList);
  523. let flag = 0;
  524. let labels = [];
  525. widgets.forEach((item, index) => {
  526. labels.push(item.label);
  527. });
  528. if (labels.length != this.unique(labels).length) {
  529. flag = 1;
  530. this.$alert("题干不能相同请仔细检查数据!", "数据错误", {
  531. confirmButtonText: "确定",
  532. type: "error",
  533. });
  534. return false;
  535. }
  536. widgets.forEach((item, index) => {
  537. if (item.label == "") {
  538. flag = 2;
  539. }
  540. if (item.type == "radio" || item.type == "checkbox") {
  541. let item_labels = [];
  542. item.items.forEach((obj, index) => {
  543. item_labels.push(obj.label);
  544. });
  545. if (item_labels.length != this.unique(item_labels).length) {
  546. flag = 3;
  547. }
  548. }
  549. });
  550. if (flag == 2) {
  551. this.$alert("题干不能为空请仔细检查数据!", "数据错误", {
  552. confirmButtonText: "确定",
  553. type: "error",
  554. });
  555. return false;
  556. }
  557. if (flag == 3) {
  558. this.$alert("选择题选项不能相同请仔细检查数据!", "数据错误", {
  559. confirmButtonText: "确定",
  560. type: "error",
  561. });
  562. return false;
  563. }
  564. let params = {
  565. name: this.title,
  566. widget: JSON.stringify(widgets),
  567. };
  568. console.log(widgets, 22222222222);
  569. if (id && !copyid) {
  570. params.id = id;
  571. this.$api.editTemplate(params).then((res) => {
  572. if (res.data.code == 0) {
  573. this.$message({
  574. type: "success",
  575. message: "成功!",
  576. });
  577. } else {
  578. this.$message.error("失败!");
  579. }
  580. this.$router.push("/message/template");
  581. });
  582. } else {
  583. this.$api.addTemplate(params).then((res) => {
  584. if (res.data.code == 0) {
  585. this.$message({
  586. type: "success",
  587. message: "成功!",
  588. });
  589. } else {
  590. this.$message.error("失败!");
  591. }
  592. this.$router.push("/message/template");
  593. });
  594. }
  595. },
  596. addWidget(i) {
  597. console.log(i);
  598. this.widgetList.push(JSON.parse(JSON.stringify(this.stdWidgetList[i])));
  599. console.log(this.widgetList);
  600. },
  601. minusOption(options, index) {
  602. if (options.length <= 1) {
  603. this.$message.error("选项不能少于1个!");
  604. } else {
  605. options.splice(index, 1);
  606. }
  607. },
  608. plusOption(options, index) {
  609. if (options.length >= 100) {
  610. this.$message.error("选项不能超过100个!");
  611. } else {
  612. options.splice(index + 1, 0, {
  613. label: "选项" + (index + 1),
  614. value: "选项值",
  615. });
  616. }
  617. },
  618. gopage(size) {
  619. if (size) {
  620. this.form.page_size = size;
  621. }
  622. this.form.page = this.$refs.pageButton.page;
  623. this.getData();
  624. },
  625. handleSelectionChange(val) {
  626. this.multipleSelection = val;
  627. },
  628. gopage1(size) {
  629. if (size) {
  630. this.form1.page_size = size;
  631. }
  632. this.form1.page = this.$refs.pageButton1.page;
  633. this.getJl();
  634. },
  635. open(data) {
  636. this.dialogFormVisible = true;
  637. this.message = { ...data };
  638. },
  639. download() {
  640. let array = this.multipleSelection,
  641. ids = [];
  642. for (let i = 0; i < array.length; i++) {
  643. ids.push(array[i].id);
  644. }
  645. ids = ids.join(",");
  646. this.$api.downloadMon({ ids: ids }).then((res) => {
  647. var elink = document.createElement("a");
  648. let blob = new Blob([res.data], { type: "application/vnd.ms-excel" });
  649. let objUrl = URL.createObjectURL(blob);
  650. console.log(res.headers["content-disposition"]);
  651. let file_name = res.headers["content-disposition"].split("=")[1];
  652. elink.download = file_name;
  653. elink.style.display = "none";
  654. elink.href = objUrl;
  655. document.body.appendChild(elink);
  656. elink.click();
  657. document.body.removeChild(elink);
  658. });
  659. },
  660. prview(id) {
  661. this.form1.enterprise_id = id;
  662. this.getJl();
  663. this.dialogFormVisible1 = true;
  664. },
  665. getJl() {
  666. var parm = this.form1;
  667. this.$api.getMonitjobList(parm).then((res) => {
  668. this.data = res.data.data.list;
  669. this.total1 = res.data.data.total;
  670. });
  671. },
  672. detail(id) {
  673. this.$router.push({
  674. path: "/company/detail",
  675. query: { id: id, page: this.form.page, page_size: this.form.page_size },
  676. });
  677. },
  678. getData() {
  679. let id = this.$route.query.id;
  680. if (id) {
  681. this.$api.getTemplate({ id: id }).then((res) => {
  682. if (res.data.code == 0) {
  683. this.widgetList = res.data.data.widget;
  684. }
  685. });
  686. }
  687. },
  688. del(id) {
  689. this.$confirm("确定删除吗?", "提示", {
  690. type: "warning",
  691. }).then(() => {
  692. this.$api.deleteEnterprise({ id: id }).then((res) => {
  693. this.$message({
  694. message: "删除成功",
  695. type: "success",
  696. });
  697. this.getData();
  698. });
  699. });
  700. },
  701. permission(name) {
  702. let permissions = this.info.permissions || [];
  703. let list = [];
  704. for (let i = 0; i < permissions.length; i++) {
  705. list.push(permissions[i].name);
  706. }
  707. if (list.indexOf(name) < 0) {
  708. return false;
  709. } else {
  710. return true;
  711. }
  712. },
  713. },
  714. created() {
  715. this.getData();
  716. },
  717. };
  718. </script>