index.vue.vm 24 KB

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