edit.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. use common\helpers\AddonHelper;
  4. ComponentHelper::loadComponentView('form-diy-menus', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components/formDiy');
  5. ComponentHelper::loadComponentView('form-diy-tool', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components/formDiy');
  6. ComponentHelper::loadComponentView('form-diy-data', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components/formDiy');
  7. ComponentHelper::loadComponentView('form-diy-model', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components/formDiy');
  8. ?>
  9. <div id="app" class="u_box">
  10. <div class="nav">表单管理</div>
  11. <div style="height: 10px;"></div>
  12. <div class="body_box">
  13. <div class="diy_box">
  14. <form-diy-menus :list="menusList" @add-prev-item="addTool"></form-diy-menus>
  15. <div class="tool_yu_nbox">
  16. <div class="diy_tool_center_box">
  17. <form-diy-tool :tool-list="toolList" :tool-index="toolIndex" @change="diyToolChange"></form-diy-tool>
  18. </div>
  19. <!-- <div class="diy_tool_box">
  20. <div class="diy-phone">
  21. <div class="phone-body">
  22. <form-diy-tool :tool-list="toolList" :tool-index="toolIndex" @change="diyToolChange"></form-diy-tool>
  23. </div>
  24. </div>
  25. </div> -->
  26. </div>
  27. <form-diy-data :active-item="toolItem" @update="updateData"></form-diy-data>
  28. </div>
  29. <div class="dorm_diy_btn_box">
  30. <el-button size="small" @click="$historyGo(-1)">取消</el-button>
  31. <el-button size="small" style="margin-left: 30px;" type="primary" @click="save">保存</el-button>
  32. </div>
  33. </div>
  34. <el-dialog :visible.sync="saveModel" width="980px">
  35. <div class="phone_save_box">
  36. <div class="phone_model_w_box">
  37. <img src="resources/img/decorate/phone.png" class="pjone_bg_box">
  38. <div class="phone_form_body_box">
  39. <div class="phone_form_title_box">
  40. {{form.title || '自定义标题'}}
  41. </div>
  42. <div class="phone_form_body_mdg_box">
  43. <div class="phone_s_img_box" v-if="form.show_heard">
  44. <img :src="form.first_img" class="img_h_bx" />
  45. </div>
  46. <form-diy-model :tool-list="toolList"></form-diy-model>
  47. </div>
  48. <el-button class="phone_sub_btn">提 交</el-button>
  49. </div>
  50. </div>
  51. <div class="phone_form_data_box">
  52. <el-form :model="form" label-position="right" label-width="100">
  53. <div class="form_data_label_box">
  54. <div class="line_form_box"></div>
  55. <span class="form_data_label_text">基本信息</span>
  56. </div>
  57. <el-form-item label="表单标题:">
  58. <el-col :span="15">
  59. <el-input v-model="form.title" placeholder="请输入标题" size="small" :maxlength="10"></el-input>
  60. </el-col>
  61. </el-form-item>
  62. <el-form-item label="头部背景:">
  63. <div class="form_hearder_bg_box">
  64. <el-switch v-model="form.show_heard" :active-value="1" :inactive-value="0"></el-switch>
  65. <div class="form_upload_img_box" v-if="form.show_heard">
  66. <com-attachment :multiple="false" :max="1" type="images" @selected="coverPic">
  67. <div class="card-upload" v-if="!form.first_img">
  68. <i class="el-icon-plus"></i>
  69. </div>
  70. <img v-if="form.first_img" :src="form.first_img" class="avatar">
  71. </com-attachment>
  72. <p class="form_upload_img_p">图片大小不能超过2M</p>
  73. </div>
  74. </div>
  75. </el-form-item>
  76. <el-form-item label="可重复填写:">
  77. <div class="form_hearder_bg_box">
  78. <el-switch v-model="form.is_repeat" :active-value="1" :inactive-value="0"></el-switch>
  79. </div>
  80. <p style="color: red">仅限于在商品详情页面点击立即购买填变动完后且下单完成的情况</p>
  81. </el-form-item>
  82. <el-form-item label="截止日期:">
  83. <span>表单截止后,用户打开表单会提示此表单已结束哦</span>
  84. <div class="form_time_chose_box">
  85. <el-radio-group v-model="form.time_type">
  86. <el-radio :label="1">永久有效</el-radio>
  87. <el-radio :label="0">自定义时间</el-radio>
  88. </el-radio-group>
  89. <div v-if="form.time_type == 0">
  90. <el-date-picker v-model="form.date" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" size="small">
  91. </el-date-picker>
  92. </div>
  93. </div>
  94. </el-form-item>
  95. <div class="form_data_label_box">
  96. <div class="line_form_box"></div>
  97. <span class="form_data_label_text">表单填写后跳转设置</span>
  98. <el-switch v-model="form.link_status" :active-value="1" :inactive-value="0" style="margin-left: 10px;"></el-switch>
  99. </div>
  100. <el-form-item v-if="form.link_status">
  101. <el-radio-group v-model="form.jump_type">
  102. <el-radio :label="0">跳转链接</el-radio>
  103. <el-radio :label="1">跳转二维码</el-radio>
  104. <el-radio :label="2">原路返回</el-radio>
  105. </el-radio-group>
  106. <p>{{form.jump_type==2 ? '客户提交表单成功后原路返回':'客户提交表单成功后跳转此链接'}}</p>
  107. </el-form-item>
  108. <el-form-item v-if="form.link_status && !form.jump_type" style="margin-top: -20px;">
  109. <el-col :span="15">
  110. <el-input type="text" placeholder="请输入以http/https开头的网址" v-model="form.link" maxlength="100" show-word-limit size="small">
  111. </el-col>
  112. </el-form-item>
  113. <el-form-item v-if="form.link_status && form.jump_type ==1" style="margin-top: -20px;" label="上传二维码:">
  114. <div class="up_qcard_img_box">
  115. <com-attachment :multiple="false" :max="1" type="images" @selected="coverQcard">
  116. <div class="card-upload" v-if="!form.qcard_img">
  117. <i class="el-icon-plus"></i>
  118. </div>
  119. <img v-if="form.qcard_img" :src="form.qcard_img" class="avatar">
  120. </com-attachment>
  121. <p class="form_upload_img_p">二维码大小不能超过2M</p>
  122. </div>
  123. </el-form-item>
  124. </el-form>
  125. </div>
  126. </div>
  127. <span slot="footer" class="dialog-footer">
  128. <el-button @click="saveModel = false">取 消</el-button>
  129. <el-button type="primary" @click="submit">确 定</el-button>
  130. </span>
  131. </el-dialog>
  132. </div>
  133. <script>
  134. new Vue({
  135. el: '#app',
  136. data() {
  137. return {
  138. menusList: [{
  139. title: '组件',
  140. toolList: []
  141. }],
  142. toolList: [],
  143. toolIndex: -1,
  144. toolItem: {},
  145. saveModel: false,
  146. id: null,
  147. form: {
  148. id: null,
  149. title: '',
  150. show_heard: 0,
  151. first_img: '',
  152. time_type: 1,
  153. date: '',
  154. link_status: 0,
  155. jump_type: 1,
  156. link: '',
  157. qcard_img: '',
  158. is_repeat: 0,
  159. },
  160. is_export: 0,
  161. agree_on: 0,
  162. componentsText: {
  163. 'single-link-text': '单行文本',
  164. 'multi-text': '多行文本',
  165. 'id-card': '身份证号码',
  166. 'drow-box': '下拉框',
  167. 'checked-tool': '多选框',
  168. 'radio-tool': '单选框',
  169. 'upload-photo': '图片',
  170. 'date-tool': '日期',
  171. 'date-range': '日期范围',
  172. 'time-tool': '时间',
  173. 'time-range': '时间范围',
  174. 'city-chose': '城市',
  175. },
  176. }
  177. },
  178. created() {
  179. if (getQuery('template_id')) {
  180. this.id = getQuery('template_id');
  181. this.getEditInfo()
  182. }
  183. this.getToolMenus()
  184. },
  185. methods: {
  186. getSettingInfo() {
  187. request({
  188. params: {
  189. r: 'smart-form/setting/info'
  190. },
  191. method: 'GET',
  192. }).then(res => {
  193. console.log('oooooooppppppppppp')
  194. this.loading = false;
  195. if (res.data.code == 0) {
  196. if (res.data.data != null) {
  197. this.is_export = res.data.data.is_export
  198. this.agree_on = res.data.data.agree_on
  199. }
  200. } else {
  201. this.$message.error(res.data.msg);
  202. }
  203. })
  204. },
  205. async getEditInfo() {
  206. request({
  207. params: {
  208. r: 'smart-form/form/edit',
  209. template_id: this.id
  210. },
  211. method: 'GET',
  212. }).then(async e => {
  213. e.data.data.columns.forEach(item => {
  214. if (item.smart_form_components_code == "single-link-text") {
  215. this.toolList.push({
  216. type: 'single-link-text',
  217. title: item.title,
  218. placeholder: item.placeholder,
  219. required: item.required,
  220. tips: item.tips,
  221. components_id: item.smart_form_components_id,
  222. content_type: item.content_type,
  223. is_export: item.is_export
  224. })
  225. } else if (item.smart_form_components_code == "multi-text") {
  226. this.toolList.push({
  227. type: 'multi-text',
  228. title: item.title,
  229. placeholder: item.placeholder,
  230. required: item.required,
  231. tips: item.tips,
  232. components_id: item.smart_form_components_id
  233. })
  234. } else if (item.smart_form_components_code == "id-card") {
  235. this.toolList.push({
  236. type: 'id-card',
  237. title: item.title,
  238. required: item.required,
  239. tips: item.tips,
  240. components_id: item.smart_form_components_id
  241. })
  242. } else if (item.smart_form_components_code == "drow-box") {
  243. let option = []
  244. item.option.forEach(o => {
  245. option.push({
  246. title: o
  247. })
  248. })
  249. this.toolList.push({
  250. type: 'drow-box',
  251. title: item.title,
  252. required: item.required,
  253. chooseList: option,
  254. components_id: item.smart_form_components_id
  255. })
  256. } else if (item.smart_form_components_code == "checked-tool") {
  257. let option = []
  258. item.option.forEach(o => {
  259. option.push({
  260. title: o
  261. })
  262. })
  263. this.toolList.push({
  264. type: 'checked-tool',
  265. title: item.title,
  266. required: item.required,
  267. chooseList: option,
  268. components_id: item.smart_form_components_id
  269. })
  270. } else if (item.smart_form_components_code == "radio-tool") {
  271. let option = []
  272. item.option.forEach(o => {
  273. option.push({
  274. title: o
  275. })
  276. })
  277. this.toolList.push({
  278. type: 'radio-tool',
  279. title: item.title,
  280. required: item.required,
  281. chooseList: option,
  282. components_id: item.smart_form_components_id
  283. })
  284. } else if (item.smart_form_components_code == "upload-photo") {
  285. this.toolList.push({
  286. type: 'upload-photo',
  287. title: item.title,
  288. required: item.required,
  289. total: item.limit,
  290. components_id: item.smart_form_components_id
  291. })
  292. } else if (item.smart_form_components_code == "date-tool") {
  293. if (Object.keys(item.extra_data) === 0) {
  294. item.extra_data = {
  295. is_enable_sms_notice: 0,
  296. sms_template_id: '',
  297. sms_template_content: '',
  298. sms_template_key: '',
  299. sms_template_name: '',
  300. send_at: '',
  301. send_day: '',
  302. vars: []
  303. }
  304. }
  305. this.toolList.push({
  306. type: 'date-tool',
  307. title: item.title,
  308. required: item.required,
  309. date: item.default,
  310. show_now_day: item.show_now_start,
  311. is_show: item.show_default,
  312. tips: item.tips,
  313. components_id: item.smart_form_components_id,
  314. extra_data: {
  315. is_enable_sms_notice: item.extra_data.is_enable_sms_notice,
  316. sms_template_id: item.extra_data.sms_template_id,
  317. sms_template_content: item.extra_data.sms_template_content,
  318. sms_template_key: item.extra_data.sms_template_key,
  319. sms_template_name: item.extra_data.sms_template_name,
  320. send_at: item.extra_data.send_at,
  321. send_day: item.extra_data.send_day,
  322. vars: item.extra_data.vars
  323. }
  324. })
  325. } else if (item.smart_form_components_code == "date-range") {
  326. this.toolList.push({
  327. type: 'date-range',
  328. title: item.title,
  329. startTitle: typeof item.tips == 'object' && item.tips.length ? item.tips[0] : '',
  330. endTitle: typeof item.tips == 'object' && item.tips.length && item.tips.length == 2 ? item.tips[1] : '',
  331. required: item.required,
  332. is_start_show: typeof item.show_default == 'object' && item.show_default.length ? item.show_default[0] : '',
  333. is_end_show: typeof item.show_default == 'object' && item.show_default.length && item.show_default.length == 2 ? item.show_default[1] : '',
  334. show_now_start: typeof item.show_now_start == 'object' && item.show_now_start.length ? item.show_now_start[0] : '',
  335. show_now_end: typeof item.show_now_start == 'object' && item.show_now_start.length && item.show_now_start.length == 2 ? item.show_now_start[1] : '',
  336. start_date: typeof item.default == 'object' && item.default.length ? item.default[0] : '',
  337. end_date: typeof item.default == 'object' && item.default.length && item.default.length == 2 ? item.default[1] : '',
  338. components_id: item.smart_form_components_id
  339. })
  340. } else if (item.smart_form_components_code == "time-tool") {
  341. this.toolList.push({
  342. type: 'time-tool',
  343. title: item.title,
  344. required: item.required,
  345. time: item.default,
  346. show_now_time: item.show_now_start,
  347. is_show: item.show_default,
  348. tips: item.tips,
  349. components_id: item.smart_form_components_id
  350. })
  351. } else if (item.smart_form_components_code == "time-range") {
  352. this.toolList.push({
  353. type: 'time-range',
  354. title: item.title,
  355. startTitle: typeof item.tips == 'object' && item.tips.length ? item.tips[0] : '',
  356. endTitle: typeof item.tips == 'object' && item.tips.length && item.tips.length == 2 ? item.tips[1] : '',
  357. required: item.required,
  358. is_start_show: typeof item.show_default == 'object' && item.show_default.length ? item.show_default[0] : '',
  359. is_end_show: typeof item.show_default == 'object' && item.show_default.length && item.show_default.length == 2 ? item.show_default[1] : '',
  360. show_now_start: typeof item.show_now_start == 'object' && item.show_now_start.length ? item.show_now_start[0] : '',
  361. show_now_end: typeof item.show_now_start == 'object' && item.show_now_start.length && item.show_now_start.length == 2 ? item.show_now_start[1] : '',
  362. start_time: typeof item.default == 'object' && item.default.length ? item.default[0] : '',
  363. end_time: typeof item.default == 'object' && item.default.length && item.default.length == 2 ? item.default[1] : '',
  364. components_id: item.smart_form_components_id
  365. })
  366. } else if (item.smart_form_components_code == "city-chose") {
  367. this.toolList.push({
  368. type: 'city-chose',
  369. title: item.title,
  370. required: item.required,
  371. city_type: item.default,
  372. components_id: item.smart_form_components_id
  373. })
  374. }
  375. })
  376. // console.log(e,1111111111111111)
  377. this.form.title = e.data.data.title
  378. this.form.first_img = e.data.data.header
  379. this.form.show_heard = e.data.data.show_header
  380. this.form.time_type = e.data.data.expire_time == -1 ? 1 : 0
  381. this.form.date = e.data.data.expire_time == -1 ? '' : await this.getDate(e.data.data.expire_time)
  382. // console.log( this.form.date,'date')
  383. this.form.jump_type = e.data.data.jump_type
  384. this.form.link_status = e.data.data.link_status
  385. this.form.qcard_img = e.data.data.jump_type == 0 ? '' : e.data.data.jump_link
  386. this.form.link = e.data.data.jump_type == 0 ? e.data.data.jump_link : ''
  387. this.form.id = e.data.data.id
  388. this.form.is_repeat = e.data.data.is_repeat
  389. }).catch(e => {});
  390. },
  391. async getDate(time) {
  392. let date = new Date(time * 1000)
  393. let years = date.getFullYear()
  394. let mouth = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)
  395. let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  396. let hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  397. let secod = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  398. let min = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  399. return years + '-' + mouth + '-' + day + ' ' + hours + ':' + secod + ':' + min
  400. },
  401. addTool(item) {
  402. console.log(item)
  403. switch (item.type) {
  404. case 'single-link-text':
  405. this.toolList.push({
  406. type: 'single-link-text',
  407. title: '',
  408. placeholder: '',
  409. required: 1,
  410. tips: '',
  411. components_id: item.components_id,
  412. is_export: 0,
  413. content_type: 0
  414. })
  415. if (this.toolList.length == 1) {
  416. this.toolIndex = 0
  417. this.toolItem = {
  418. type: 'single-link-text',
  419. title: '',
  420. placeholder: '',
  421. required: 1,
  422. tips: '',
  423. components_id: item.components_id,
  424. is_export: 0,
  425. content_type: 0
  426. }
  427. }
  428. this.scrollToBottom()
  429. break;
  430. case 'multi-text':
  431. this.toolList.push({
  432. type: 'multi-text',
  433. title: '',
  434. placeholder: '',
  435. required: 1,
  436. tips: '',
  437. components_id: item.components_id
  438. })
  439. if (this.toolList.length == 1) {
  440. this.toolIndex = 0
  441. this.toolItem = {
  442. type: 'multi-text',
  443. title: '',
  444. placeholder: '',
  445. required: 1,
  446. tips: '',
  447. components_id: item.components_id
  448. }
  449. }
  450. this.scrollToBottom()
  451. break;
  452. case 'id-card':
  453. this.toolList.push({
  454. type: 'id-card',
  455. title: '',
  456. required: 1,
  457. tips: '',
  458. components_id: item.components_id
  459. })
  460. if (this.toolList.length == 1) {
  461. this.toolItem = {
  462. type: 'id-card',
  463. title: '',
  464. required: 1,
  465. tips: '',
  466. components_id: item.components_id
  467. }
  468. this.toolIndex = 0
  469. }
  470. this.scrollToBottom()
  471. break;
  472. case 'drow-box':
  473. this.toolList.push({
  474. type: 'drow-box',
  475. title: '',
  476. required: 1,
  477. chooseList: [{
  478. title: '选项一'
  479. }, {
  480. title: '选项二'
  481. }],
  482. components_id: item.components_id
  483. })
  484. if (this.toolList.length == 1) {
  485. this.toolItem = {
  486. type: 'drow-box',
  487. title: '',
  488. required: 1,
  489. chooseList: [{
  490. title: '选项一'
  491. }, {
  492. title: '选项二'
  493. }],
  494. components_id: item.components_id
  495. }
  496. this.toolIndex = 0
  497. }
  498. this.scrollToBottom()
  499. break;
  500. case 'checked-tool':
  501. this.toolList.push({
  502. type: 'checked-tool',
  503. title: '',
  504. required: 1,
  505. chooseList: [{
  506. title: '选项一'
  507. }, {
  508. title: '选项二'
  509. }],
  510. components_id: item.components_id
  511. })
  512. if (this.toolList.length == 1) {
  513. this.toolItem = {
  514. type: 'checked-tool',
  515. title: '',
  516. required: 1,
  517. chooseList: [{
  518. title: '选项一'
  519. }, {
  520. title: '选项二'
  521. }],
  522. components_id: item.components_id
  523. }
  524. this.toolIndex = 0
  525. }
  526. this.scrollToBottom()
  527. break;
  528. case 'radio-tool':
  529. this.toolList.push({
  530. type: 'radio-tool',
  531. title: '',
  532. required: 1,
  533. chooseList: [{
  534. title: '选项一'
  535. }, {
  536. title: '选项二'
  537. }],
  538. components_id: item.components_id
  539. })
  540. if (this.toolList.length == 1) {
  541. this.toolItem = {
  542. type: 'radio-tool',
  543. title: '',
  544. required: 1,
  545. chooseList: [{
  546. title: '选项一'
  547. }, {
  548. title: '选项二'
  549. }],
  550. components_id: item.components_id
  551. }
  552. this.toolIndex = 0
  553. }
  554. this.scrollToBottom()
  555. break;
  556. case 'upload-photo':
  557. this.toolList.push({
  558. type: 'upload-photo',
  559. title: '',
  560. required: 1,
  561. total: 3,
  562. components_id: item.components_id
  563. })
  564. if (this.toolList.length == 1) {
  565. this.toolItem = {
  566. type: 'upload-photo',
  567. title: '',
  568. required: 1,
  569. total: 3,
  570. components_id: item.components_id
  571. }
  572. this.toolIndex = 0
  573. }
  574. this.scrollToBottom()
  575. break;
  576. case 'date-tool':
  577. this.toolList.push({
  578. type: 'date-tool',
  579. title: '',
  580. required: 1,
  581. tips: '',
  582. is_show: 1,
  583. date: '',
  584. show_now_day: 1,
  585. components_id: item.components_id
  586. })
  587. if (this.toolList.length == 1) {
  588. this.toolItem = {
  589. type: 'date-tool',
  590. title: '',
  591. required: 1,
  592. tips: '',
  593. is_show: 1,
  594. date: '',
  595. show_now_day: 1,
  596. components_id: item.components_id
  597. }
  598. this.toolIndex = 0
  599. }
  600. this.scrollToBottom()
  601. break;
  602. case 'date-range':
  603. this.toolList.push({
  604. type: 'date-range',
  605. title: '',
  606. startTitle: '',
  607. endTitle: '',
  608. required: 1,
  609. is_start_show: 1,
  610. is_end_show: 1,
  611. show_now_start: 1,
  612. show_now_end: 1,
  613. start_date: '',
  614. end_date: '',
  615. components_id: item.components_id
  616. })
  617. if (this.toolList.length == 1) {
  618. this.toolItem = {
  619. type: 'date-range',
  620. title: '',
  621. startTitle: '',
  622. endTitle: '',
  623. required: 1,
  624. is_start_show: 1,
  625. is_end_show: 1,
  626. show_now_start: 1,
  627. show_now_end: 1,
  628. start_date: '',
  629. end_date: '',
  630. components_id: item.components_id
  631. }
  632. this.toolIndex = 0
  633. }
  634. this.scrollToBottom()
  635. break;
  636. case 'time-tool':
  637. this.toolList.push({
  638. type: 'time-tool',
  639. title: '',
  640. required: 1,
  641. tips: '',
  642. is_show: 1,
  643. time: '',
  644. show_now_time: 1,
  645. components_id: item.components_id
  646. })
  647. if (this.toolList.length == 1) {
  648. this.toolItem = {
  649. type: 'time-tool',
  650. title: '',
  651. required: 1,
  652. tips: '',
  653. is_show: 1,
  654. time: '',
  655. show_now_time: 1,
  656. components_id: item.components_id
  657. }
  658. this.toolIndex = 0
  659. }
  660. this.scrollToBottom()
  661. break;
  662. case 'time-range':
  663. this.toolList.push({
  664. type: 'time-range',
  665. title: '',
  666. startTitle: '',
  667. endTitle: '',
  668. required: 1,
  669. is_start_show: 1,
  670. is_end_show: 1,
  671. start_time: '',
  672. show_now_start: 1,
  673. show_now_end: 1,
  674. end_time: '',
  675. components_id: item.components_id
  676. })
  677. if (this.toolList.length == 1) {
  678. this.toolItem = {
  679. type: 'time-range',
  680. title: '',
  681. startTitle: '',
  682. endTitle: '',
  683. required: 1,
  684. is_start_show: 1,
  685. is_end_show: 1,
  686. start_time: '',
  687. show_now_start: 1,
  688. show_now_end: 1,
  689. end_time: '',
  690. components_id: item.components_id
  691. }
  692. this.toolIndex = 0
  693. }
  694. this.scrollToBottom()
  695. break;
  696. case 'city-chose':
  697. this.toolList.push({
  698. type: 'city-chose',
  699. title: '',
  700. required: 1,
  701. city_type: 1,
  702. components_id: item.components_id
  703. })
  704. if (this.toolList.length == 1) {
  705. this.toolItem = {
  706. type: 'city-chose',
  707. title: '',
  708. required: 1,
  709. city_type: 1,
  710. components_id: item.components_id
  711. }
  712. this.toolIndex = 0
  713. }
  714. this.scrollToBottom()
  715. break;
  716. }
  717. console.log(this.toolList, 'this.toolList')
  718. },
  719. coverPic(e) {
  720. this.form.first_img = e[0].url
  721. },
  722. coverQcard(e) {
  723. this.form.qcard_img = e[0].url
  724. },
  725. getToolMenus() {
  726. let that = this
  727. request({
  728. params: {
  729. r: 'smart-form/components/index',
  730. },
  731. method: 'GET',
  732. }).then(res => {
  733. console.log(res, '9090000')
  734. res.data.data.list.forEach(item => {
  735. that.menusList[0].toolList.push({
  736. type: item.code,
  737. components_id: item.id,
  738. img: _diy_img_prefix + item.icon,
  739. title: item.title
  740. })
  741. })
  742. })
  743. },
  744. // changeIndex(index){
  745. // this.toolIndex = index
  746. // },
  747. //滚动到底部
  748. scrollToBottom() {
  749. this.$nextTick(() => {
  750. let box = this.$el.querySelector(".diy_tool_center_box")
  751. box.scrollTop = box.scrollHeight
  752. })
  753. },
  754. //
  755. diyToolChange(e) {
  756. switch (e.type) {
  757. case 'change-index':
  758. this.toolIndex = e.index
  759. this.toolItem = {
  760. ...this.toolList[this.toolIndex]
  761. }
  762. break;
  763. case 'change-move':
  764. this.toolIndex = e.index
  765. this.toolList = e.list
  766. this.toolItem = {
  767. ...this.toolList[this.toolIndex]
  768. }
  769. break;
  770. case 'delete':
  771. this.toolList.splice(e.index, 1)
  772. this.toolIndex = this.toolIndex - 1 > 0 ? this.toolIndex - 1 : 0
  773. this.toolItem = {
  774. ...this.toolList[this.toolIndex]
  775. }
  776. break;
  777. case 'copy':
  778. this.toolList.splice(e.index, 0, e.item)
  779. break;
  780. }
  781. },
  782. updateData(e) {
  783. // console.log(JSON.stringify(this.toolList))
  784. this.toolItem = e
  785. this.toolList[this.toolIndex] = e
  786. this.toolList = JSON.parse(JSON.stringify((this.toolList)))
  787. },
  788. save() {
  789. console.log(this.toolList, 'hhhhhhhh');
  790. if (this.toolList.length <= 0) {
  791. this.$message.error(`请至少选择一个表单组件`);
  792. return;
  793. }
  794. for (let i = 0; i < this.toolList.length; i++) {
  795. if (this.toolList[i].title == '' || this.toolList[i].title == ' ') {
  796. this.$message.error(`请完善${this.componentsText[this.toolList[i].type]}组件的标题`);
  797. return;
  798. }
  799. }
  800. this.saveModel = true
  801. },
  802. submit() {
  803. let obj = {
  804. form: {
  805. ...this.form,
  806. },
  807. toolList: this.toolList
  808. }
  809. obj.form.date = obj.form.time_type == 1 ? -1 : obj.form.date
  810. obj.form.time_type = obj.form.time_type == 1 ? -1 : 0
  811. request({
  812. params: {
  813. r: this.id ? 'smart-form/form/edit' : 'smart-form/form/add',
  814. },
  815. method: 'post',
  816. data: {
  817. ...obj
  818. }
  819. }).then(res => {
  820. console.log(res)
  821. if (res.data.code == 0) {
  822. this.saveModel = false
  823. navigateTo({
  824. r: 'smart-form/form/index'
  825. })
  826. } else {
  827. this.$message.error(res.data.msg)
  828. }
  829. })
  830. }
  831. }
  832. })
  833. // 拦截页面卸载
  834. window.onbeforeunload = function(e) {
  835. var e = window.event || e;
  836. e.returnValue = ("确定离开当前页面吗?");
  837. }
  838. </script>
  839. <style scoped>
  840. .diy_tool_center_box {
  841. width: 100%;
  842. overflow-y: auto;
  843. height: 80vh;
  844. }
  845. .phone_sub_btn {
  846. border-radius: 0;
  847. width: 100%;
  848. height: 27px;
  849. font-size: 12px;
  850. color: #ffffff;
  851. background: #d9001b;
  852. line-height: 0.5;
  853. /* line-height: 27px; */
  854. }
  855. .phone_s_img_box {
  856. width: 100%;
  857. height: 144px;
  858. background: #aaa;
  859. }
  860. .img_h_bx {
  861. width: 100%;
  862. height: 100%;
  863. }
  864. .up_qcard_img_box {
  865. padding-top: 10px;
  866. box-sizing: border-box;
  867. display: flex;
  868. align-items: flex-start;
  869. flex-direction: column;
  870. justify-content: flex-start;
  871. }
  872. .form_time_chose_box {
  873. width: 100%;
  874. }
  875. .form_upload_img_p {
  876. font-size: 12px;
  877. color: #7f7f7f;
  878. margin-top: 20px;
  879. }
  880. .form_upload_img_box {
  881. padding-left: 60px;
  882. box-sizing: border-box;
  883. margin-top: 10px;
  884. }
  885. .avatar-uploader .el-upload {
  886. border: 1px dashed #d9d9d9;
  887. border-radius: 6px;
  888. cursor: pointer;
  889. position: relative;
  890. overflow: hidden;
  891. }
  892. .avatar-uploader .el-upload:hover {
  893. border-color: #409EFF;
  894. }
  895. .avatar-uploader-icon {
  896. font-size: 28px;
  897. color: #8c939d;
  898. width: 60px;
  899. height: 60px;
  900. line-height: 60px;
  901. text-align: center;
  902. }
  903. .avatar {
  904. width: 60px;
  905. height: 60px;
  906. display: block;
  907. }
  908. .form_hearder_bg_box {
  909. width: 100%;
  910. /* display: flex;
  911. align-items: flex-start;
  912. justify-content: flex-start;
  913. flex-direction: column; */
  914. }
  915. .form_data_label_text {
  916. font-size: 14px;
  917. color: #333;
  918. margin-left: 10px;
  919. }
  920. .form_data_label_box {
  921. width: 100%;
  922. display: flex;
  923. align-items: center;
  924. margin-bottom: 20px;
  925. }
  926. .line_form_box {
  927. width: 2px;
  928. height: 25px;
  929. background: #d9001b;
  930. }
  931. .phone_form_data_box {
  932. flex: 1;
  933. padding-left: 30px;
  934. padding-top: 20px;
  935. box-sizing: border-box;
  936. }
  937. .phone_form_body_mdg_box {
  938. flex: 1;
  939. width: 100%;
  940. overflow-y: auto;
  941. background: #ffffff;
  942. }
  943. .phone_form_title_box {
  944. width: 100%;
  945. height: 24px;
  946. background: #ffffff;
  947. font-size: 12px;
  948. color: #000;
  949. display: flex;
  950. align-items: center;
  951. justify-content: center;
  952. }
  953. .phone_form_body_box {
  954. width: 230px;
  955. height: 412px;
  956. overflow: hidden;
  957. display: flex;
  958. align-items: center;
  959. justify-content: flex-start;
  960. flex-direction: column;
  961. background: #f5f6f7;
  962. position: absolute;
  963. top: 59px;
  964. left: 15px;
  965. }
  966. .phone_save_box {
  967. width: 100%;
  968. display: flex;
  969. align-items: flex-start;
  970. justify-content: space-between;
  971. padding: 10px 20px;
  972. box-sizing: border-box;
  973. }
  974. .phone_model_w_box {
  975. width: 262px;
  976. height: 533px;
  977. position: relative;
  978. /* background: url('resources/img/decorate/phone.png')no-repeat;
  979. background-size: 100%; */
  980. }
  981. .pjone_bg_box {
  982. width: 100%;
  983. height: 100%;
  984. }
  985. .dorm_diy_btn_box {
  986. width: 100%;
  987. height: 50px;
  988. display: flex;
  989. align-items: center;
  990. justify-content: center;
  991. }
  992. .u_box {
  993. width: 100%;
  994. height: 100vh;
  995. display: flex;
  996. align-items: center;
  997. justify-content: center;
  998. flex-direction: column;
  999. }
  1000. .nav {
  1001. width: 100%;
  1002. background: #ffffff;
  1003. border-radius: 5px;
  1004. padding: 26px 24px;
  1005. }
  1006. .body_box {
  1007. width: 100%;
  1008. flex: 1;
  1009. /* margin-top: 5px; */
  1010. background: #ffffff;
  1011. overflow: hidden;
  1012. overflow-y: auto;
  1013. }
  1014. .diy_box {
  1015. width: 100%;
  1016. display: flex;
  1017. align-items: center;
  1018. }
  1019. .diy_tool_box {
  1020. height: 100%;
  1021. overflow-y: auto;
  1022. }
  1023. .tool_yu_nbox {
  1024. flex: 1;
  1025. /* display: flex;
  1026. align-items: center;
  1027. justify-content: center; */
  1028. background: #fff;
  1029. height: 80vh;
  1030. overflow: hidden;
  1031. }
  1032. .diy-phone {
  1033. width: 410px;
  1034. border: 1px solid #bfbfbf;
  1035. border-radius: 4px;
  1036. background: #fafafa;
  1037. padding: 20px 12px;
  1038. position: relative;
  1039. }
  1040. .phone-body {
  1041. min-height: 650px;
  1042. width: 377px;
  1043. border: 1px solid #bfbfbf;
  1044. border-radius: 4px;
  1045. background: #f5f6f7;
  1046. position: relative;
  1047. }
  1048. </style>