button.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <section>
  3. <div id="setting" >
  4. <div id="Attribute">
  5. <div style="color: red;font-weight: bolder;text-align: center;font-size: 14px;">按 键</div>
  6. <table :title="form && form.id ? '编辑' : '新增' " :model="form">
  7. <tr>
  8. <td>名称</td>
  9. <td colspan="3"><input type="text" v-model="form_copy.name"/></td>
  10. </tr>
  11. <tr>
  12. <td>框长</td>
  13. <td colspan="3">
  14. <input type="text" style="width:50px;margin-right: 14px;" v-model="form_copy.width" />
  15. 框高
  16. <input type="text" style="width:50px" v-model="form_copy.height"/></td>
  17. </tr>
  18. <tr>
  19. <td>字体</td>
  20. <td>
  21. <select v-model="form_copy.fontFamily" style="width:80px;border: #0342c5 1px solid;">
  22. <option value="黑体">黑体</option>
  23. <option value="楷体">楷体</option>
  24. <option value="微软雅黑">微软雅黑</option>
  25. <option value="宋体">宋体</option>
  26. </select>
  27. </td>
  28. <td>字高</td>
  29. <td><input type="text" v-model="form_copy.fontSize"/></td>
  30. </tr>
  31. <tr>
  32. <td>字组</td>
  33. <td colspan="3"><input type="text" v-model="form_copy.content" /></td>
  34. </tr>
  35. <tr>
  36. <td colspan="4">
  37. <label>着色 <input type="color" v-model="form_copy.color" style="width: 40px;"/></label>
  38. &nbsp;
  39. <button type="primary" @click="fittingPreview">预览</button>
  40. &nbsp;
  41. <button type="primary" @click="fittingSave">提交</button>
  42. </td>
  43. </tr>
  44. </table>
  45. </div>
  46. <div id="fitting">
  47. <input type="button" id="fitting_button" v-bind:style="{width:form.width+'px',height:form.height+'px',fontFamily:form.fontFamily,fontSize:form.fontSize+'px',background:form.color}" v-bind:value="form.content"/>
  48. </div>
  49. </div>
  50. </section>
  51. </template>
  52. <script>
  53. let findAll = function() {
  54. this.$axios.get("/api/accessories/button/findAll").then(response => {
  55. if (response.data.code == 0) {
  56. this.rows = response.data.list;
  57. }
  58. })
  59. .catch(error => {
  60. console.log(error);
  61. this.message = error;
  62. });
  63. };
  64. let fittingSave = function(){
  65. this.$axios.post('/api/accessories/button/saveOrUpdate', this.form).then(response => {
  66. if (response.data.code == 0) {
  67. this.findAll()
  68. this.form = {}
  69. }
  70. })
  71. .catch(error => {
  72. console.log(error);
  73. this.message = error;
  74. });
  75. }
  76. let fittingEdit = function(index){
  77. this.form = this.rows[index]
  78. }
  79. let settingShow = function(){
  80. this.form = {}
  81. }
  82. let fittingPreview = function(){
  83. this.form = Object.assign({}, this.form_copy)
  84. }
  85. export default {
  86. data() {
  87. return {
  88. rows: [],
  89. form: {},
  90. form_copy: {}
  91. };
  92. },
  93. mounted: function() {
  94. this.findAll();
  95. },
  96. methods: {
  97. findAll,
  98. fittingSave,
  99. fittingEdit,
  100. settingShow,
  101. fittingPreview
  102. }
  103. };
  104. </script>