index.vue.vm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  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
  17. v-model="queryParams.${column.javaField}"
  18. placeholder="请输入${comment}"
  19. clearable
  20. size="small"
  21. @keyup.enter.native="handleQuery"
  22. />
  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 size="small">
  27. <el-option
  28. v-for="dict in ${column.javaField}Options"
  29. :key="dict.dictValue"
  30. :label="dict.dictLabel"
  31. :value="dict.dictValue"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
  36. <el-form-item label="${comment}" prop="${column.javaField}">
  37. <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
  38. <el-option label="请选择字典生成" value="" />
  39. </el-select>
  40. </el-form-item>
  41. #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
  42. <el-form-item label="${comment}" prop="${column.javaField}">
  43. <el-date-picker clearable size="small"
  44. v-model="queryParams.${column.javaField}"
  45. type="date"
  46. value-format="yyyy-MM-dd"
  47. placeholder="选择${comment}">
  48. </el-date-picker>
  49. </el-form-item>
  50. #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  51. <el-form-item label="${comment}">
  52. <el-date-picker
  53. v-model="daterange${AttrName}"
  54. size="small"
  55. style="width: 240px"
  56. value-format="yyyy-MM-dd"
  57. type="daterange"
  58. range-separator="-"
  59. start-placeholder="开始日期"
  60. end-placeholder="结束日期"
  61. ></el-date-picker>
  62. </el-form-item>
  63. #end
  64. #end
  65. #end
  66. <el-form-item>
  67. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  68. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  69. </el-form-item>
  70. </el-form>
  71. <el-row :gutter="10" class="mb8">
  72. <el-col :span="1.5">
  73. <el-button
  74. type="primary"
  75. plain
  76. icon="el-icon-plus"
  77. size="mini"
  78. @click="handleAdd"
  79. v-hasPermi="['${moduleName}:${businessName}:add']"
  80. >新增</el-button>
  81. </el-col>
  82. <el-col :span="1.5">
  83. <el-button
  84. type="success"
  85. plain
  86. icon="el-icon-edit"
  87. size="mini"
  88. :disabled="single"
  89. @click="handleUpdate"
  90. v-hasPermi="['${moduleName}:${businessName}:edit']"
  91. >修改</el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="danger"
  96. plain
  97. icon="el-icon-delete"
  98. size="mini"
  99. :disabled="multiple"
  100. @click="handleDelete"
  101. v-hasPermi="['${moduleName}:${businessName}:remove']"
  102. >删除</el-button>
  103. </el-col>
  104. <el-col :span="1.5">
  105. <el-button
  106. type="warning"
  107. plain
  108. icon="el-icon-download"
  109. size="mini"
  110. :loading="exportLoading"
  111. @click="handleExport"
  112. v-hasPermi="['${moduleName}:${businessName}:export']"
  113. >导出</el-button>
  114. </el-col>
  115. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  116. </el-row>
  117. <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
  118. <el-table-column type="selection" width="55" align="center" />
  119. #foreach($column in $columns)
  120. #set($javaField=$column.javaField)
  121. #set($parentheseIndex=$column.columnComment.indexOf("("))
  122. #if($parentheseIndex != -1)
  123. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  124. #else
  125. #set($comment=$column.columnComment)
  126. #end
  127. #if($column.pk)
  128. <el-table-column label="${comment}" align="center" prop="${javaField}" v-if="${column.list}"/>
  129. #elseif($column.list && $column.htmlType == "datetime")
  130. <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
  131. <template slot-scope="scope">
  132. <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
  133. </template>
  134. </el-table-column>
  135. #elseif($column.list && "" != $column.dictType)
  136. <el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
  137. #elseif($column.list && "" != $javaField)
  138. <el-table-column label="${comment}" align="center" prop="${javaField}" />
  139. #end
  140. #end
  141. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  142. <template slot-scope="scope">
  143. <el-button
  144. size="mini"
  145. type="text"
  146. icon="el-icon-edit"
  147. @click="handleUpdate(scope.row)"
  148. v-hasPermi="['${moduleName}:${businessName}:edit']"
  149. >修改</el-button>
  150. <el-button
  151. size="mini"
  152. type="text"
  153. icon="el-icon-delete"
  154. @click="handleDelete(scope.row)"
  155. v-hasPermi="['${moduleName}:${businessName}:remove']"
  156. >删除</el-button>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. <pagination
  161. v-show="total>0"
  162. :total="total"
  163. :page.sync="queryParams.pageNum"
  164. :limit.sync="queryParams.pageSize"
  165. @pagination="getList"
  166. />
  167. <!-- 添加或修改${functionName}对话框 -->
  168. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  169. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  170. #foreach($column in $columns)
  171. #set($field=$column.javaField)
  172. #if($column.insert && !$column.pk)
  173. #if(($column.usableColumn) || (!$column.superColumn))
  174. #set($parentheseIndex=$column.columnComment.indexOf("("))
  175. #if($parentheseIndex != -1)
  176. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  177. #else
  178. #set($comment=$column.columnComment)
  179. #end
  180. #set($dictType=$column.dictType)
  181. #if($column.htmlType == "input")
  182. <el-form-item label="${comment}" prop="${field}">
  183. <el-input v-model="form.${field}" placeholder="请输入${comment}" />
  184. </el-form-item>
  185. #elseif($column.htmlType == "imageUpload")
  186. <el-form-item label="${comment}">
  187. <imageUpload v-model="form.${field}"/>
  188. </el-form-item>
  189. #elseif($column.htmlType == "fileUpload")
  190. <el-form-item label="${comment}">
  191. <fileUpload v-model="form.${field}"/>
  192. </el-form-item>
  193. #elseif($column.htmlType == "editor")
  194. <el-form-item label="${comment}">
  195. <editor v-model="form.${field}" :min-height="192"/>
  196. </el-form-item>
  197. #elseif($column.htmlType == "select" && "" != $dictType)
  198. <el-form-item label="${comment}" prop="${field}">
  199. <el-select v-model="form.${field}" placeholder="请选择${comment}">
  200. <el-option
  201. v-for="dict in ${field}Options"
  202. :key="dict.dictValue"
  203. :label="dict.dictLabel"
  204. #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
  205. ></el-option>
  206. </el-select>
  207. </el-form-item>
  208. #elseif($column.htmlType == "select" && $dictType)
  209. <el-form-item label="${comment}" prop="${field}">
  210. <el-select v-model="form.${field}" placeholder="请选择${comment}">
  211. <el-option label="请选择字典生成" value="" />
  212. </el-select>
  213. </el-form-item>
  214. #elseif($column.htmlType == "checkbox" && "" != $dictType)
  215. <el-form-item label="${comment}">
  216. <el-checkbox-group v-model="form.${field}">
  217. <el-checkbox
  218. v-for="dict in ${field}Options"
  219. :key="dict.dictValue"
  220. :label="dict.dictValue">
  221. {{dict.dictLabel}}
  222. </el-checkbox>
  223. </el-checkbox-group>
  224. </el-form-item>
  225. #elseif($column.htmlType == "checkbox" && $dictType)
  226. <el-form-item label="${comment}">
  227. <el-checkbox-group v-model="form.${field}">
  228. <el-checkbox>请选择字典生成</el-checkbox>
  229. </el-checkbox-group>
  230. </el-form-item>
  231. #elseif($column.htmlType == "radio" && "" != $dictType)
  232. <el-form-item label="${comment}">
  233. <el-radio-group v-model="form.${field}">
  234. <el-radio
  235. v-for="dict in ${field}Options"
  236. :key="dict.dictValue"
  237. #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
  238. >{{dict.dictLabel}}</el-radio>
  239. </el-radio-group>
  240. </el-form-item>
  241. #elseif($column.htmlType == "radio" && $dictType)
  242. <el-form-item label="${comment}">
  243. <el-radio-group v-model="form.${field}">
  244. <el-radio label="1">请选择字典生成</el-radio>
  245. </el-radio-group>
  246. </el-form-item>
  247. #elseif($column.htmlType == "datetime")
  248. <el-form-item label="${comment}" prop="${field}">
  249. <el-date-picker clearable size="small"
  250. v-model="form.${field}"
  251. type="datetime"
  252. value-format="yyyy-MM-dd HH:mm:ss"
  253. placeholder="选择${comment}">
  254. </el-date-picker>
  255. </el-form-item>
  256. #elseif($column.htmlType == "textarea")
  257. <el-form-item label="${comment}" prop="${field}">
  258. <el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
  259. </el-form-item>
  260. #end
  261. #end
  262. #end
  263. #end
  264. #if($table.sub)
  265. <el-divider content-position="center">${subTable.functionName}信息</el-divider>
  266. <el-row :gutter="10" class="mb8">
  267. <el-col :span="1.5">
  268. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button>
  269. </el-col>
  270. <el-col :span="1.5">
  271. <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button>
  272. </el-col>
  273. </el-row>
  274. <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
  275. <el-table-column type="selection" width="50" align="center" />
  276. <el-table-column label="序号" align="center" prop="index" width="50"/>
  277. #foreach($column in $subTable.columns)
  278. #set($javaField=$column.javaField)
  279. #set($parentheseIndex=$column.columnComment.indexOf("("))
  280. #if($parentheseIndex != -1)
  281. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  282. #else
  283. #set($comment=$column.columnComment)
  284. #end
  285. #if($column.pk || $javaField == ${subTableFkclassName})
  286. #elseif($column.list && "" != $javaField)
  287. <el-table-column label="$comment" prop="${javaField}">
  288. <template slot-scope="scope">
  289. <el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
  290. </template>
  291. </el-table-column>
  292. #end
  293. #end
  294. </el-table>
  295. #end
  296. </el-form>
  297. <div slot="footer" class="dialog-footer">
  298. <el-button type="primary" @click="submitForm">确 定</el-button>
  299. <el-button @click="cancel">取 消</el-button>
  300. </div>
  301. </el-dialog>
  302. </div>
  303. </template>
  304. <script>
  305. import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
  306. #foreach($column in $columns)
  307. #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
  308. import ImageUpload from '@/components/ImageUpload';
  309. #break
  310. #end
  311. #end
  312. #foreach($column in $columns)
  313. #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
  314. import FileUpload from '@/components/FileUpload';
  315. #break
  316. #end
  317. #end
  318. #foreach($column in $columns)
  319. #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
  320. import Editor from '@/components/Editor';
  321. #break
  322. #end
  323. #end
  324. export default {
  325. name: "${BusinessName}",
  326. components: {
  327. #foreach($column in $columns)
  328. #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
  329. ImageUpload,
  330. #break
  331. #end
  332. #end
  333. #foreach($column in $columns)
  334. #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
  335. FileUpload,
  336. #break
  337. #end
  338. #end
  339. #foreach($column in $columns)
  340. #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
  341. Editor,
  342. #break
  343. #end
  344. #end
  345. },
  346. data() {
  347. return {
  348. // 遮罩层
  349. loading: true,
  350. // 导出遮罩层
  351. exportLoading: false,
  352. // 选中数组
  353. ids: [],
  354. #if($table.sub)
  355. // 子表选中数据
  356. checked${subClassName}: [],
  357. #end
  358. // 非单个禁用
  359. single: true,
  360. // 非多个禁用
  361. multiple: true,
  362. // 显示搜索条件
  363. showSearch: true,
  364. // 总条数
  365. total: 0,
  366. // ${functionName}表格数据
  367. ${businessName}List: [],
  368. #if($table.sub)
  369. // ${subTable.functionName}表格数据
  370. ${subclassName}List: [],
  371. #end
  372. // 弹出层标题
  373. title: "",
  374. // 是否显示弹出层
  375. open: false,
  376. #foreach ($column in $columns)
  377. #set($parentheseIndex=$column.columnComment.indexOf("("))
  378. #if($parentheseIndex != -1)
  379. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  380. #else
  381. #set($comment=$column.columnComment)
  382. #end
  383. #if(${column.dictType} != '')
  384. // $comment字典
  385. ${column.javaField}Options: [],
  386. #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  387. #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  388. // $comment时间范围
  389. daterange${AttrName}: [],
  390. #end
  391. #end
  392. // 查询参数
  393. queryParams: {
  394. pageNum: 1,
  395. pageSize: 10,
  396. #foreach ($column in $columns)
  397. #if($column.query)
  398. $column.javaField: undefined#if($velocityCount != $columns.size()),#end
  399. #end
  400. #end
  401. },
  402. // 表单参数
  403. form: {},
  404. // 表单校验
  405. rules: {
  406. #foreach ($column in $columns)
  407. #if($column.required)
  408. #set($parentheseIndex=$column.columnComment.indexOf("("))
  409. #if($parentheseIndex != -1)
  410. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  411. #else
  412. #set($comment=$column.columnComment)
  413. #end
  414. $column.javaField: [
  415. { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
  416. ]#if($velocityCount != $columns.size()),#end
  417. #end
  418. #end
  419. }
  420. };
  421. },
  422. created() {
  423. this.getList();
  424. #foreach ($column in $columns)
  425. #if(${column.dictType} != '')
  426. this.getDicts("${column.dictType}").then(response => {
  427. this.${column.javaField}Options = response.data;
  428. });
  429. #end
  430. #end
  431. },
  432. methods: {
  433. /** 查询${functionName}列表 */
  434. getList() {
  435. this.loading = true;
  436. #foreach ($column in $columns)
  437. #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  438. this.queryParams.params = {};
  439. #break
  440. #end
  441. #end
  442. #foreach ($column in $columns)
  443. #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  444. #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  445. if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
  446. this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
  447. this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
  448. }
  449. #end
  450. #end
  451. list${BusinessName}(this.queryParams).then(response => {
  452. this.${businessName}List = response.rows;
  453. this.total = response.total;
  454. this.loading = false;
  455. });
  456. },
  457. #foreach ($column in $columns)
  458. #if(${column.dictType} != '')
  459. #set($parentheseIndex=$column.columnComment.indexOf("("))
  460. #if($parentheseIndex != -1)
  461. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  462. #else
  463. #set($comment=$column.columnComment)
  464. #end
  465. // $comment字典翻译
  466. ${column.javaField}Format(row, column) {
  467. return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
  468. },
  469. #end
  470. #end
  471. // 取消按钮
  472. cancel() {
  473. this.open = false;
  474. this.reset();
  475. },
  476. // 表单重置
  477. reset() {
  478. this.form = {
  479. #foreach ($column in $columns)
  480. #if($column.htmlType == "radio")
  481. $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
  482. #elseif($column.htmlType == "checkbox")
  483. $column.javaField: []#if($velocityCount != $columns.size()),#end
  484. #else
  485. $column.javaField: undefined#if($velocityCount != $columns.size()),#end
  486. #end
  487. #end
  488. };
  489. #if($table.sub)
  490. this.${subclassName}List = [];
  491. #end
  492. this.resetForm("form");
  493. },
  494. /** 搜索按钮操作 */
  495. handleQuery() {
  496. this.queryParams.pageNum = 1;
  497. this.getList();
  498. },
  499. /** 重置按钮操作 */
  500. resetQuery() {
  501. #foreach ($column in $columns)
  502. #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
  503. #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  504. this.daterange${AttrName} = [];
  505. #end
  506. #end
  507. this.resetForm("queryForm");
  508. this.handleQuery();
  509. },
  510. // 多选框选中数据
  511. handleSelectionChange(selection) {
  512. this.ids = selection.map(item => item.${pkColumn.javaField})
  513. this.single = selection.length!==1
  514. this.multiple = !selection.length
  515. },
  516. /** 新增按钮操作 */
  517. handleAdd() {
  518. this.reset();
  519. this.open = true;
  520. this.title = "添加${functionName}";
  521. },
  522. /** 修改按钮操作 */
  523. handleUpdate(row) {
  524. this.reset();
  525. const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
  526. get${BusinessName}(${pkColumn.javaField}).then(response => {
  527. this.form = response.data;
  528. #foreach ($column in $columns)
  529. #if($column.htmlType == "checkbox")
  530. this.form.$column.javaField = this.form.${column.javaField}.split(",");
  531. #end
  532. #end
  533. #if($table.sub)
  534. this.${subclassName}List = response.data.${subclassName}List;
  535. #end
  536. this.open = true;
  537. this.title = "修改${functionName}";
  538. });
  539. },
  540. /** 提交按钮 */
  541. submitForm() {
  542. this.#[[$]]#refs["form"].validate(valid => {
  543. if (valid) {
  544. #foreach ($column in $columns)
  545. #if($column.htmlType == "checkbox")
  546. this.form.$column.javaField = this.form.${column.javaField}.join(",");
  547. #end
  548. #end
  549. #if($table.sub)
  550. this.form.${subclassName}List = this.${subclassName}List;
  551. #end
  552. if (this.form.${pkColumn.javaField} != null) {
  553. update${BusinessName}(this.form).then(response => {
  554. this.msgSuccess("修改成功");
  555. this.open = false;
  556. this.getList();
  557. });
  558. } else {
  559. add${BusinessName}(this.form).then(response => {
  560. this.msgSuccess("新增成功");
  561. this.open = false;
  562. this.getList();
  563. });
  564. }
  565. }
  566. });
  567. },
  568. /** 删除按钮操作 */
  569. handleDelete(row) {
  570. const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
  571. this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
  572. confirmButtonText: "确定",
  573. cancelButtonText: "取消",
  574. type: "warning"
  575. }).then(function() {
  576. return del${BusinessName}(${pkColumn.javaField}s);
  577. }).then(() => {
  578. this.getList();
  579. this.msgSuccess("删除成功");
  580. })
  581. },
  582. #if($table.sub)
  583. /** ${subTable.functionName}序号 */
  584. row${subClassName}Index({ row, rowIndex }) {
  585. row.index = rowIndex + 1;
  586. },
  587. /** ${subTable.functionName}添加按钮操作 */
  588. handleAdd${subClassName}() {
  589. let obj = {};
  590. #foreach($column in $subTable.columns)
  591. #if($column.pk || $column.javaField == ${subTableFkclassName})
  592. #elseif($column.list && "" != $javaField)
  593. obj.$column.javaField = "";
  594. #end
  595. #end
  596. this.${subclassName}List.push(obj);
  597. },
  598. /** ${subTable.functionName}删除按钮操作 */
  599. handleDelete${subClassName}() {
  600. if (this.checked${subClassName}.length == 0) {
  601. this.$alert("请先选择要删除的${subTable.functionName}数据", "提示", { confirmButtonText: "确定", });
  602. } else {
  603. this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1);
  604. }
  605. },
  606. /** 单选框选中数据 */
  607. handle${subClassName}SelectionChange(selection) {
  608. if (selection.length > 1) {
  609. this.$refs.${subclassName}.clearSelection();
  610. this.$refs.${subclassName}.toggleRowSelection(selection.pop());
  611. } else {
  612. this.checked${subClassName} = selection;
  613. }
  614. },
  615. #end
  616. /** 导出按钮操作 */
  617. handleExport() {
  618. const queryParams = this.queryParams;
  619. this.$confirm('是否确认导出所有${functionName}数据项?', "警告", {
  620. confirmButtonText: "确定",
  621. cancelButtonText: "取消",
  622. type: "warning"
  623. }).then(() => {
  624. this.exportLoading = true;
  625. return export${BusinessName}(queryParams);
  626. }).then(response => {
  627. this.download(response.msg);
  628. this.exportLoading = false;
  629. })
  630. }
  631. }
  632. };
  633. </script>