style.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template id="smart-form-style">
  2. <div >
  3. <diy-style-contain :title=" activeItem.funcListItem.formData ?activeItem.funcListItem.formData.title : '新增名称'" class="fill-border-top">
  4. <com-pick-link class="node-add-btn" @selected="selectNavUrl" :pick-type="pickType" :default-tabs="[{name: 'addons',children:['smart_form'] }]">
  5. <div class="add-goods-btn">{{activeItem.funcListItem.columns ? '切换' : '新增'}}</div>
  6. </com-pick-link>
  7. </diy-style-contain>
  8. <diy-style-contain title="按钮设置" class="fill-border-top" >
  9. <div class="order-broadcaset-row" flex="cross:center">
  10. <div class="leabl">背景色</div>
  11. <div flex="cross:center">
  12. <el-color-picker class="color-box" flex="cross:center" @change="styleChange($event, 'brodcastBgColor')" v-model="brodcastBgColor"></el-color-picker>
  13. <el-input v-model="brodcastBgColor" maxlength="8" @focus="iptSelect($event)" class="diy-text-btn"></el-input>
  14. </div>
  15. </div>
  16. <div flex="cross:center">
  17. <div style="width:80px;text-align:center">文字</div>
  18. <el-input placeholder="标题栏" v-model="value" :maxlength="8" show-word-limit @input="titleChange">
  19. </el-input>
  20. </div>
  21. <div class="pick-goods" style="padding: 10px;background: #fff;">
  22. <div class="icon-set-items" flex="cross:center">
  23. <div class="icon-set-list-name diy-text-font">链接</div>
  24. <div class="icon-set-list-content" flex="cross:center">
  25. <com-pick-link @selected="selectedUrl($event)" :default-tabs="['other']">
  26. <diy-url :text="selectUrl"></diy-url>
  27. </com-pick-link>
  28. </div>
  29. </div>
  30. <!-- <diy-operation-list v-if="selectUrl" v-model="showLineList" @on-change="onChange5"> </diy-operation-list> -->
  31. </div>
  32. <diy-color top-name="选择颜色"
  33. :color-infos="colorInfos"
  34. :str-color="defColor"
  35. @chang="updateColor"
  36. ></diy-color>
  37. <diy-size-setting top-name="边距"
  38. :size-infos="sizeInfos"
  39. :max-value="50"
  40. @chang="sliderChange($event, 'margin')"
  41. ></diy-size-setting>
  42. <diy-size-setting top-name="圆角设置"
  43. :size-infos="radiusInfos"
  44. :max-value="20"
  45. @chang="RadiusChange($event, 'radius')"
  46. ></diy-size-setting>
  47. </diy-style-contain>
  48. </div>
  49. </template>
  50. <script>
  51. Vue.component('smart-form-style',{
  52. template: '#smart-form-style',
  53. name: "smart-form-style",
  54. mixins: [basicMixins],
  55. data(){
  56. return{
  57. brodcastBgColor: '#F10009', // 背景色
  58. selectUrl: "",
  59. value: "",
  60. colorInfos: ['底部背景' ,'组件背景', '文字颜色'],
  61. defColor: ['#fff', '#fff', '#000'],
  62. sizeInfos: ['上边距', '下边距','左右边距'],
  63. pickType: ['smart_form'],
  64. radiusInfos:['上圆角','下园角'],
  65. formList:[],
  66. item:{}
  67. }
  68. },
  69. // created(){
  70. // this.reslut = {
  71. // ...this.activeItem
  72. // }
  73. // },
  74. // watch:{
  75. // activeItem(newVal,oldVal){
  76. // this.reslut = {
  77. // ...newVal
  78. // }
  79. // }
  80. // },
  81. props: {
  82. activeItem: {
  83. type: Object,
  84. default () {
  85. return {}
  86. }
  87. }
  88. },
  89. methods:{
  90. init() {
  91. basicMixins.methods.init.call(this); // 以前的数据调用一下
  92. if(this.result.data.btnLink){
  93. this.selectUrl = this.result.data.btnLink[0].open_type
  94. }
  95. if(this.result.data.padArr){
  96. this.sizeInfos = this.result.data.padArr
  97. }
  98. if(this.result.data.colorInfos){
  99. this.colorInfos = this.result.data.colorInfos
  100. }
  101. if(this.result.data.radiusArr){
  102. this.radiusInfos = this.result.data.radiusArr
  103. }
  104. if(this.result.data.btnTitle){
  105. this.value = this.result.data.btnTitle
  106. }
  107. if(this.result.computedStyle.btnBg){
  108. this.brodcastBgColor = this.result.computedStyle.btnBg
  109. }
  110. // this.updataInfos()
  111. },
  112. styleChange(e, type) {
  113. if(!this.result.computedStyle.btnBg) this.$set(this.result.funcListItem,'btnBg','');
  114. this.result.computedStyle.btnBg = e
  115. this.$emit("update", this.result)
  116. },
  117. selectNavUrl(e){
  118. console.log(e,'[[[[[[[[[]]]]]]]]]',typeof e)
  119. // return
  120. let that = this
  121. if(e.length){
  122. if(!that.result.funcListItem.formData) that.$set(that.result.funcListItem,'formData',{});
  123. that.result.funcListItem.formData = e[0]
  124. if(!that.result.funcListItem.columns) that.$set(that.result.funcListItem,'columns',[]);
  125. if(!that.result.funcListItem.template_id) that.$set(that.result.funcListItem,'template_id','');
  126. that.result.funcListItem.template_id = e[0].id
  127. that.result.funcListItem.columns = []
  128. e[0].columns.forEach(item=>{
  129. if(item.smart_form_components_code == "single-link-text"){
  130. that.result.funcListItem.columns.push({
  131. type:'single-link-text',
  132. id:item.id,
  133. title:item.title,
  134. placeholder:item.placeholder,
  135. required:item.required,
  136. tips:item.tips,
  137. components_id:item.smart_form_components_id,
  138. is_export:item.is_export,
  139. content_type:item.content_type,
  140. value:''
  141. })
  142. }
  143. else if(item.smart_form_components_code == "multi-text"){
  144. that.result.funcListItem.columns.push({
  145. type:'multi-text',
  146. title:item.title,
  147. id:item.id,
  148. placeholder:item.placeholder,
  149. required:item.required,
  150. tips:item.tips,
  151. components_id:item.smart_form_components_id,
  152. value:''
  153. })
  154. }
  155. else if(item.smart_form_components_code == "id-card"){
  156. that.result.funcListItem.columns.push({
  157. type:'id-card',
  158. id:item.id,
  159. title:item.title,
  160. required:item.required,
  161. tips:item.tips,
  162. components_id:item.smart_form_components_id,
  163. value:''
  164. })
  165. }
  166. else if(item.smart_form_components_code == "drow-box"){
  167. let option = []
  168. item.option.forEach(o=>{
  169. option.push({
  170. title:o
  171. })
  172. })
  173. that.result.funcListItem.columns.push({
  174. type:'drow-box',
  175. title:item.title,
  176. id:item.id,
  177. required:item.required,
  178. chooseList:option,
  179. components_id:item.smart_form_components_id,
  180. value:''
  181. })
  182. }
  183. else if(item.smart_form_components_code == "checked-tool"){
  184. let option = []
  185. item.option.forEach(o=>{
  186. option.push({
  187. title:o
  188. })
  189. })
  190. that.result.funcListItem.columns.push({
  191. type:'checked-tool',
  192. title:item.title,
  193. id:item.id,
  194. required:item.required,
  195. chooseList:option,
  196. components_id:item.smart_form_components_id,
  197. value:''
  198. })
  199. }
  200. else if(item.smart_form_components_code == "radio-tool"){
  201. let option = []
  202. item.option.forEach(o=>{
  203. option.push({
  204. title:o
  205. })
  206. })
  207. that.result.funcListItem.columns.push({
  208. type:'radio-tool',
  209. title:item.title,
  210. id:item.id,
  211. required:item.required,
  212. chooseList:option,
  213. components_id:item.smart_form_components_id,
  214. value:''
  215. })
  216. }
  217. else if(item.smart_form_components_code == "upload-photo"){
  218. that.result.funcListItem.columns.push({
  219. type:'upload-photo',
  220. title:item.title,
  221. id:item.id,
  222. required:item.required,
  223. total:item.limit,
  224. value:''
  225. })
  226. }
  227. else if(item.smart_form_components_code == "date-tool"){
  228. that.result.funcListItem.columns.push({
  229. type:'date-tool',
  230. title:item.title,
  231. id:item.id,
  232. required:item.required,
  233. // date:item.show_default,
  234. date:item.show_default ? (item.show_now_start ? new Date().getFullYear() + '-' + ((new Date().getMonth()+1) < 10 ? ('0'+(new Date().getMonth()+1)) : (new Date().getMonth()+1) )+'-'+new Date().getDate() : item.default) : '',
  235. show_now_day:item.show_now_start,
  236. is_show:item.show_default,
  237. tips:item.tips,
  238. components_id:item.smart_form_components_id,
  239. // value:''
  240. value:item.show_default ? (item.show_now_start ? new Date().getFullYear() + '-' + ((new Date().getMonth()+1) < 10 ? ('0'+(new Date().getMonth()+1)) : (new Date().getMonth()+1) )+'-'+new Date().getDate() : item.default) : ''
  241. })
  242. }
  243. else if(item.smart_form_components_code == "date-range"){
  244. that.result.funcListItem.columns.push({
  245. type:'date-range',
  246. title:item.title,
  247. startTitle: typeof item.tips == 'object' && item.tips.length ? item.tips[0] : '',
  248. endTitle:typeof item.tips == 'object' && item.tips.length && item.tips.length == 2 ? item.tips[1] : '',
  249. id:item.id,
  250. required:item.required,
  251. is_start_show:typeof item.show_default == 'object' && item.show_default.length ? item.show_default[0] : '' ,
  252. is_end_show:typeof item.show_default == 'object' && item.show_default.length && item.show_default.length == 2 ? item.show_default[1] : '',
  253. show_now_start: typeof item.show_now_start == 'object' && item.show_now_start.length ? item.show_now_start[0] : '' ,
  254. 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] : '',
  255. start_date: typeof item.default == 'object' && item.default.length ? item.default[0] : '',
  256. end_date:typeof item.default == 'object' && item.default.length && item.default.length == 2 ? item.default[1] : '',
  257. components_id:item.smart_form_components_id,
  258. value:''
  259. })
  260. }
  261. else if(item.smart_form_components_code == "time-tool"){
  262. that.result.funcListItem.columns.push({
  263. type:'time-tool',
  264. title:item.title,
  265. required:item.required,
  266. time:item.show_default ? (item.show_now_start ?(new Date().getHours() < 10 ? '0'+new Date().getHours() : new Date().getHours() ) +':'+(new Date().getMinutes() < 10 ? '0'+new Date().getMinutes() : new Date().getMinutes() ): item.default ) : '',
  267. // time:item.show_default,
  268. id:item.id,
  269. show_now_time:item.show_now_start,
  270. is_show:item.show_default,
  271. tips:item.tips,
  272. components_id:item.smart_form_components_id,
  273. value:item.show_default ? (item.show_now_start ? (new Date().getHours() < 10 ? '0'+new Date().getHours() : new Date().getHours() ) +':'+(new Date().getMinutes() < 10 ? '0'+new Date().getMinutes() : new Date().getMinutes() ) : item.default ) : ''
  274. // value:''
  275. })
  276. }
  277. else if(item.smart_form_components_code =="time-range"){
  278. that.result.funcListItem.columns.push({
  279. type:'time-range',
  280. title:item.title,
  281. startTitle: typeof item.tips == 'object' && item.tips.length ? item.tips[0] : '',
  282. endTitle:typeof item.tips == 'object' && item.tips.length && item.tips.length == 2 ? item.tips[1] : '',
  283. required:item.required,
  284. id:item.id,
  285. is_start_show:typeof item.show_default == 'object' && item.show_default.length ? item.show_default[0] : '' ,
  286. is_end_show:typeof item.show_default == 'object' && item.show_default.length && item.show_default.length == 2 ? item.show_default[1] : '',
  287. show_now_start: typeof item.show_now_start == 'object' && item.show_now_start.length ? item.show_now_start[0] : '' ,
  288. 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] : '',
  289. start_time:typeof item.default == 'object' && item.default.length ? item.default[0] : '',
  290. end_time:typeof item.default == 'object' && item.default.length && item.default.length == 2 ? item.default[1] : '',
  291. components_id:item.smart_form_components_id,
  292. value:''
  293. })
  294. }
  295. else if(item.smart_form_components_code =="city-chose"){
  296. that.result.funcListItem.columns.push({
  297. type:'city-chose',
  298. title:item.title,
  299. required:item.required,
  300. id:item.id,
  301. city_type:item.default,
  302. components_id:item.smart_form_components_id,
  303. value:''
  304. })
  305. }
  306. })
  307. this.$emit("update", this.result)
  308. }
  309. },
  310. titleChange() {
  311. if(!this.result.data.btnTitle) this.$set(this.result.data,'btnTitle','');
  312. this.result.data.btnTitle = this.value
  313. this.$emit("update", this.result)
  314. },
  315. selectedUrl(value) {
  316. if(value.length){
  317. if(!this.result.data.btnLink) this.$set(this.result.data,'btnLink','');
  318. this.result.data.btnLink = value
  319. this.$emit("update", this.result)
  320. // var item = getObjValue(value[0], ["params"], {})
  321. this.selectUrl = value[0].open_type
  322. }
  323. // this.showLineList[0].value = 10
  324. // this.updateData(Object.assign({
  325. // count: 10
  326. // }, item), 'commCate')
  327. },
  328. sliderChange(arr, type) { // 上下边距
  329. if(!this.result.computedStyle.padTop) this.$set(this.result.computedStyle,'padTop',0);
  330. if(!this.result.computedStyle.padBot) this.$set(this.result.computedStyle,'padBot',0);
  331. if(!this.result.computedStyle.padLr) this.$set(this.result.computedStyle,'padLr',0);
  332. if(!this.result.data.padArr) this.$set(this.result.data,'padArr',[]);
  333. this.result.data.padArr = arr
  334. this.result.computedStyle.padTop = arr[0].value
  335. this.result.computedStyle.padBot = arr[1].value
  336. this.result.computedStyle.padLr = arr[2].value
  337. this.$emit("update", this.result)
  338. },
  339. updateColor(e) { // 选择颜色
  340. this.colorInfos = e;
  341. // if(this.result.data.colorInfos){
  342. // this.colorInfos = this.result.data.colorInfos;
  343. // } else {
  344. // this.result.data.colorInfos = this.colorInfos;
  345. // }
  346. if(!this.result.data.colorInfos) this.$set(this.result.data,'colorInfos',[]);
  347. this.result.data.colorInfos = this.colorInfos
  348. if(!this.result.computedStyle.bodyBg) this.$set(this.result.computedStyle,'bodyBg','');
  349. if(!this.result.computedStyle.tempBg) this.$set(this.result.computedStyle,'tempBg','');
  350. if(!this.result.computedStyle.textColor) this.$set(this.result.computedStyle,'textColor','');
  351. this.result.computedStyle.bodyBg = this.colorInfos[0].color
  352. this.result.computedStyle.tempBg = this.colorInfos[1].color
  353. this.result.computedStyle.textColor = this.colorInfos[2].color
  354. this.$emit("update", this.result)
  355. },
  356. RadiusChange(arr,type){
  357. if(!this.result.computedStyle.radiusTop) this.$set(this.result.computedStyle,'radiusTop',0);
  358. if(!this.result.computedStyle.radiusBot) this.$set(this.result.computedStyle,'radiusBot',0);
  359. if(!this.result.data.radiusArr) this.$set(this.result.data,'radiusArr',[]);
  360. this.result.computedStyle.radiusTop = arr[0].value
  361. this.result.computedStyle.radiusBot = arr[1].value
  362. this.result.data.radiusArr = arr
  363. this.$emit("update", this.result)
  364. }
  365. }
  366. })
  367. </script>
  368. <style>
  369. .form_style_upload_fm{
  370. width: 100%;
  371. height: 34px;
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. border: 1px dashed rgba(215, 215, 215, 1);
  376. border-radius: 8px;
  377. cursor: pointer;
  378. font-size: 14px;
  379. color: #a6a6a6;
  380. }
  381. </style>