Setting.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div style="overflow:auto">
  3. <Toptitle title="项目设置">
  4. </Toptitle>
  5. <div style="padding: 10px" class="setting" >
  6. <Card :padding="0" v-for="(item,index) in switch_list" :key="index">
  7. <Input slot="title" v-if="item.title_type" @on-blur="change_title(item,1)" v-model="item.title" autofocus='true' style="width:90%"></Input>
  8. <p slot="title" v-else @click="change_title(item)">{{item.title}}</p>
  9. <CellGroup>
  10. <Cell :title="_item.title" v-for="(_item,_index) in item.content" :key="_index">
  11. <i-switch v-model="_item.state" slot="extra" @on-change="change($event,_index,item)" />
  12. </Cell>
  13. </CellGroup>
  14. <Tooltip max-width="200" :content="item.remark"
  15. style="min-width:200px;position:absolute;right:-168px;top:169px;cursor: pointer">
  16. <Icon type="md-help-circle" size="24" />
  17. </Tooltip>
  18. </Card>
  19. <Card :title="item.title" :padding="0" v-for="(item,index) in logo_list" :key="index" >
  20. <Input slot="title" v-if="item.title_type" @on-blur="change_title(item,1)" v-model="item.title" autofocus='true' style="width:80%"></Input>
  21. <p slot="title" v-else @click="change_title(item)">{{item.title}}</p>
  22. <a @click="upload(item)" class="upload_pic">上传</a>
  23. <div class="product-add">
  24. <div
  25. class="items"
  26. v-if="item.content"
  27. >
  28. <img
  29. @click="looks(item.content)"
  30. :src="$store.state.ip + item.content"
  31. alt=""
  32. />
  33. <Icon
  34. size="20"
  35. @click="delItems(item)"
  36. class="delete-img"
  37. type="ios-close-circle"
  38. />
  39. </div>
  40. <div class="add-items" v-show="!item.content">
  41. <div class="_item">
  42. <Icon size="50" type="ios-add" />
  43. </div>
  44. <input
  45. @change="changeIpt($event,index)"
  46. type="file"
  47. class="ipt"
  48. />
  49. </div>
  50. </div>
  51. <Tooltip max-width="200" :content="item.remark"
  52. style="min-width:200px;position:absolute;right:-168px;top:169px;cursor: pointer">
  53. <Icon type="md-help-circle" size="24" />
  54. </Tooltip>
  55. </Card>
  56. <Card v-for="(item,index) in text_list" :key="index" :title="item.title" style="width:520px">
  57. <Input slot="title" v-if="item.title_type" @on-blur="change_title(item,1)" v-model="item.title" autofocus='true' style="width:80%"></Input>
  58. <p slot="title" v-else @click="change_title(item)">{{item.title}}</p>
  59. <a @click="upload(item)" class="upload_text">保存</a>
  60. <div v-for="(_item,_index) in item.content" :key="_index" style="position: relative;top:-40px;display:flex;margin-top:20px">
  61. <label style="width:80px;margin-right:60px">{{_item.title}}:</label> <Input v-model="_item.value" />
  62. </div>
  63. <Tooltip max-width="200" :content="item.remark"
  64. style="min-width:200px;position:absolute;right:-168px;top:169px;cursor: pointer">
  65. <Icon type="md-help-circle" size="24" />
  66. </Tooltip>
  67. </Card>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. export default {
  73. data(){
  74. return {
  75. switchValue: true,
  76. switch1:true,
  77. tempItem:{
  78. url:[],
  79. },
  80. logo_title:'',
  81. content:[],
  82. logo_title:{},
  83. tempItem_op:{},
  84. logo_remark:'',
  85. switch_list:[],
  86. logo_list:[],
  87. text_list:[],
  88. }
  89. },
  90. mounted(){
  91. this.axios.get('/api/basics_config_list').then(res=>{
  92. this.content = res.data;
  93. this.content.forEach(item =>{//sub_type 1 文本 2 开关 3 图片
  94. if(item.sub_type == 2){
  95. this.switch_list.push(item);
  96. this.switch_list.forEach(item=>{
  97. item.title_type = false;
  98. })
  99. }
  100. if(item.sub_type == 3){
  101. this.logo_list.push(item);
  102. this.logo_title = item.title
  103. this.logo_remark = item.remark
  104. this.tempItem_op = item
  105. this.tempItem.url = item.content.split(',')
  106. this.logo_list.forEach(item=>{
  107. item.title_type = false;
  108. })
  109. }
  110. if(item.sub_type == 1){
  111. this.text_list.push(item);
  112. this.text_list.forEach(item=>{
  113. item.title_type = false;
  114. })
  115. }
  116. })
  117. })
  118. },
  119. methods:{
  120. change_title(item,type){
  121. item.title_type = !item.title_type;
  122. this.$forceUpdate();
  123. if(type){
  124. this.upload(item)
  125. }
  126. },
  127. change(e,index,item){
  128. this.axios.post('/api/basics_config_edit',item).then(res=>{
  129. console.log(res)
  130. })
  131. },
  132. upload(item){
  133. this.axios.post('/api/basics_config_edit',item).then(res=>{
  134. if(res.code == 200){
  135. this.$Message.success(res.msg)
  136. }
  137. })
  138. },
  139. looks(img) {
  140. const array = [{ img_url: img }];
  141. this.$previewImg({
  142. list: array,
  143. baseUrl: this.$store.state.ip,
  144. baseImgField: "img_url",
  145. baseTitleField: "",
  146. });
  147. },
  148. delItems(item) {
  149. item.content = null;
  150. },
  151. changeIpt(e,index) {
  152. let file = e.target.files[0];
  153. this.postImg(file,index);
  154. // e.target.value = null;
  155. },
  156. postImg(file, index) {
  157. let formData = new FormData();
  158. formData.append("file", file);
  159. this.axios.post("/api/upload_pic", formData).then((res) => {
  160. this.$nextTick(() => {
  161. this.logo_list[index].content= res.data.url;
  162. // this.$forceUpdate();
  163. });
  164. });
  165. },
  166. }
  167. }
  168. </script>
  169. <style scoped lang='scss'>
  170. .setting{
  171. margin-top:10px ;
  172. display: flex;
  173. flex-wrap: wrap;
  174. }
  175. .product-add {
  176. position: relative;
  177. top: -25px;
  178. height: 140px;
  179. .ipt {
  180. position: absolute;
  181. width: 100%;
  182. height: 100%;
  183. opacity: 0;
  184. cursor: pointer;
  185. outline: none;
  186. top: 0;
  187. left: 0;
  188. }
  189. .add-items {
  190. position: relative;
  191. left: 50%;
  192. top:40% ;
  193. transform: translate(-50%,-50%);
  194. width: 40px;
  195. height: 40px;
  196. border: 1px dotted #e7e7e7;
  197. border-radius: 5px;
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. overflow: hidden;
  202. background: #f4f5f7;
  203. .item {
  204. width: 46px;
  205. height: 46px;
  206. background: #3764ff;
  207. opacity: 0.6;
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. border-radius: 50%;
  212. color: #fff;
  213. }
  214. }
  215. .items {
  216. width: 100px;
  217. height: 100px;
  218. margin-bottom: 10px;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. margin-right: 10px;
  223. border-radius: 5px;
  224. position: relative;
  225. left:50%;
  226. top: 40%;
  227. transform: translate(-50%,-50%);
  228. img {
  229. max-width: 100px;
  230. max-height: 100px;
  231. }
  232. }
  233. }
  234. /deep/ .ivu-card{
  235. background: #f8f8f9;
  236. width: 250px;
  237. height: 200px;
  238. margin: 10px;
  239. border-radius: 20px;
  240. position: relative;
  241. .ivu-card:hover{
  242. box-shadow: darkgrey 2px 2px 2px 2px ;//边框阴影
  243. }
  244. }
  245. /deep/ .ivu-card-head{
  246. border-bottom: none;
  247. height: 60px;
  248. p{
  249. font-weight: 800;
  250. }
  251. }
  252. /deep/ .ivu-card-body{
  253. height: 200px;
  254. }
  255. .delete-img{
  256. position: relative;
  257. top:-35px
  258. }
  259. .upload_pic{
  260. position: relative;
  261. top: -44px;
  262. right: -200px;
  263. color: red;
  264. }
  265. .upload_text{
  266. position: relative;
  267. top: -60px;
  268. right: -444px;
  269. color: red;
  270. }
  271. /deep/ .ivu-cell-group{
  272. position: relative;
  273. top: -10px;
  274. }
  275. </style>