singleColumn.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. <input type="text" style="width:50px" v-model="form_copy.height"/></td>
  16. </tr>
  17. <tr>
  18. <td>字体</td>
  19. <td>
  20. <select v-model="form_copy.fontFamily" style="width:80px;border: #0342c5 1px solid;">
  21. <option value="黑体">黑体</option>
  22. <option value="楷体">楷体</option>
  23. <option value="微软雅黑">微软雅黑</option>
  24. <option value="宋体">宋体</option>
  25. </select>
  26. </td>
  27. <td>字高</td>
  28. <td><input type="text" v-model="form_copy.fontSize"/></td>
  29. </tr>
  30. <tr>
  31. <td>字距</td>
  32. <td colspan="3"><input type="text" v-model="form_copy.letterSpacing" /></td>
  33. </tr>
  34. <tr>
  35. <td>字组</td>
  36. <td colspan="3"><input type="text" v-model="form_copy.content" /></td>
  37. </tr>
  38. <tr>
  39. <td colspan="4">
  40. <button type="primary" @click="fittingPreview">预览</button>
  41. &nbsp;
  42. <button type="primary" @click="fittingSave">提交</button>
  43. </td>
  44. </tr>
  45. </table>
  46. </div>
  47. <div id="fitting">
  48. <table>
  49. <tr><td v-bind:style="{width:form.width+'px',height:form.height+'px',fontFamily:form.fontFamily,fontSize:form.fontSize+'px',letterSpacing:form.letterSpacing+'px'}">{{form.content}}</td></tr>
  50. <tr><td></td></tr>
  51. </table>
  52. </div>
  53. </div>
  54. </section>
  55. </template>
  56. <script>
  57. let findAll = function() {
  58. this.$axios.get("/api/columns/singleColumn/findAll").then(response => {
  59. if (response.data.code == 0) {
  60. this.rows = response.data.list;
  61. }
  62. })
  63. .catch(error => {
  64. console.log(error);
  65. this.message = error;
  66. });
  67. };
  68. let fittingSave = function(){
  69. this.$axios.post('/api/columns/singleColumn/saveOrUpdate', this.form).then(response => {
  70. if (response.data.code == 0) {
  71. this.findAll()
  72. this.form = {}
  73. }
  74. })
  75. .catch(error => {
  76. console.log(error);
  77. this.message = error;
  78. });
  79. }
  80. let fittingEdit = function(index){
  81. this.form = this.rows[index]
  82. }
  83. let settingShow = function(){
  84. this.form = {}
  85. }
  86. let fittingPreview = function(){
  87. this.form = Object.assign({}, this.form_copy)
  88. }
  89. export default {
  90. data() {
  91. return {
  92. rows: [],
  93. form: {},
  94. form_copy: {}
  95. };
  96. },
  97. mounted: function() {
  98. this.findAll();
  99. },
  100. methods: {
  101. findAll,
  102. fittingSave,
  103. fittingEdit,
  104. settingShow,
  105. fittingPreview
  106. }
  107. };
  108. </script>
  109. <style scoped>
  110. #fitting table{
  111. border: 1px solid #000;
  112. border-collapse: collapse;
  113. margin: auto;
  114. margin-top: 70px;
  115. }
  116. #fitting table tr td{
  117. width: 50px;
  118. height: 30px;
  119. border: 1px solid #000;
  120. }
  121. </style>