index.vue.vm 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent v-show="showSearch">
  4. #foreach($column in $columns)
  5. #if($column.query)
  6. #set($dictType=$column.dictType)
  7. #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  8. #set($parentheseIndex=$column.columnComment.indexOf("("))
  9. #if($parentheseIndex != -1)
  10. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  11. #else
  12. #set($comment=$column.columnComment)
  13. #end
  14. #if($column.htmlType == "input")
  15. <el-form-item label="${comment}" prop="${column.javaField}">
  16. <el-input v-model="queryParams.${column.javaField}" placeholder="请输入${comment}" @keyup.enter.native="handleQuery" clearable class="inp"/>
  17. </el-form-item>
  18. #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
  19. <el-form-item label="${comment}" prop="${column.javaField}">
  20. <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable class="se">
  21. <el-option v-for="dict in dict.type.${dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
  22. </el-select>
  23. </el-form-item>
  24. #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
  25. <el-form-item label="${comment}" prop="${column.javaField}">
  26. <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable class="se">
  27. <el-option label="请选择字典生成" value="" />
  28. </el-select>
  29. </el-form-item>
  30. #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
  31. <el-form-item label="${comment}" prop="${column.javaField}">
  32. <el-date-picker clearable v-model="queryParams.${column.javaField}" type="date" value-format="yyyy-MM-dd" placeholder="请选择${comment}"></el-date-picker>
  33. </el-form-item>
  34. #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  35. <el-form-item label="${comment}">
  36. <el-date-picker
  37. v-model="daterange${AttrName}"
  38. style="width: 240px"
  39. value-format="yyyy-MM-dd"
  40. type="daterange"
  41. range-separator="-"
  42. start-placeholder="开始日期"
  43. end-placeholder="结束日期"
  44. ></el-date-picker>
  45. </el-form-item>
  46. #end
  47. #end
  48. #end
  49. <el-form-item>
  50. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  51. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  52. </el-form-item>
  53. </el-form>
  54. <el-row :gutter="10" class="mb8">
  55. <el-button type="primary" icon="el-icon-plus" :disabled="ids.length > 0" @click="op('add')" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
  56. <el-button type="success" icon="el-icon-edit" :disabled="ids.length != 1" @click="op('edit',ids)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
  57. <el-button type="danger" icon="el-icon-delete" :disabled="ids.length == 0" @click="del" v-hasPermi="['${moduleName}:${businessName}:remove']">删除{{ids.length>0?'('+ids.length+')':''}}</el-button>
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. <el-table :data="response.rows" border @selection-change="selects" height="calc(100vh - 270px)">
  61. <el-table-column type="selection" width="55" align="center" />
  62. #foreach($column in $columns)
  63. #set($javaField=$column.javaField)
  64. #set($parentheseIndex=$column.columnComment.indexOf("("))
  65. #if($parentheseIndex != -1)
  66. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  67. #else
  68. #set($comment=$column.columnComment)
  69. #end
  70. #if($column.pk)
  71. <el-table-column label="${comment}" align="center" prop="${javaField}" />
  72. #elseif($column.list && $column.htmlType == "datetime")
  73. <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
  74. <template slot-scope="scope">
  75. <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
  76. </template>
  77. </el-table-column>
  78. #elseif($column.list && $column.htmlType == "imageUpload")
  79. <el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
  80. <template slot-scope="scope">
  81. <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
  82. </template>
  83. </el-table-column>
  84. #elseif($column.list && "" != $column.dictType)
  85. <el-table-column label="${comment}" align="center" prop="${javaField}">
  86. <template slot-scope="scope">
  87. #if($column.htmlType == "checkbox")
  88. <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
  89. #else
  90. <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
  91. #end
  92. </template>
  93. </el-table-column>
  94. #elseif($column.list && "" != $javaField)
  95. <el-table-column label="${comment}" align="center" prop="${javaField}" />
  96. #end
  97. #end
  98. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  99. <template slot-scope="scope">
  100. <el-button size="mini" type="text" icon="el-icon-edit" @click="op('edit',scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
  101. <el-button size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
  102. </template>
  103. </el-table-column>
  104. <template slot="empty">
  105. <el-empty></el-empty>
  106. </template>
  107. </el-table>
  108. <pagination v-if="response.total>0" :total="response.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  109. </div>
  110. </template>
  111. <script>
  112. import edit from './edit'
  113. export default {
  114. name: "${BusinessName}",
  115. #if(${dicts} != '')
  116. dicts: [${dicts}],
  117. #end
  118. data() {
  119. return {
  120. ids: [],
  121. showSearch:true,
  122. response: {},
  123. #if($table.sub)
  124. // ${subTable.functionName}表格数据
  125. ${subclassName}List: [],
  126. #end
  127. #foreach ($column in $columns)
  128. #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  129. #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  130. daterange${AttrName}: [],
  131. #end
  132. #end
  133. queryParams: {
  134. pageNum: 1,
  135. pageSize: 10,
  136. #foreach ($column in $columns)
  137. #if($column.query)
  138. $column.javaField: null#if($foreach.count != $columns.size()),#end
  139. #end
  140. #end
  141. orderByColumn: 'id',
  142. isAsc: 'desc'
  143. }
  144. };
  145. },
  146. created() {
  147. this.getList();
  148. },
  149. methods: {
  150. getList() {
  151. this.ajax({ url: '/${moduleName}/${businessName}/list', data: this.queryParams }).then(response => {
  152. this.response = response;
  153. });
  154. },
  155. handleQuery() {
  156. this.queryParams.pageNum = 1;
  157. this.getList();
  158. },
  159. resetQuery() {
  160. this.resetForm("queryForm");
  161. this.handleQuery();
  162. },
  163. selects(rows) {
  164. this.ids = rows.map(item => item.${pkColumn.javaField})
  165. },
  166. op(tag, row) {
  167. if (tag == 'add') {
  168. this.iframe({ obj: edit, param: {}, title:'新增',width: '45%', height: '55%'});
  169. }
  170. if (tag == 'edit') {
  171. const id = row.${pkColumn.javaField} || this.ids[0];
  172. this.iframe({ obj: edit, param: {id: id}, title:'编辑',width: '50%', height: '50%'});
  173. }
  174. },
  175. del(row) {
  176. this.$confirm('是否确认删除选中数据?', '警告', { type: 'warning' }).then(() => {
  177. this.get({ url: '/${moduleName}/${businessName}/remove/' + (row.id || this.ids) }).then(response => {
  178. this.$modal.msgSuccess('删除成功');
  179. this.getList();
  180. });
  181. });
  182. }
  183. }
  184. };
  185. </script>