editTable.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. <template>
  2. <el-card>
  3. <el-row type="flex" justify="space-between">
  4. <el-col :span="1.5" style="display: flex; align-items: center;">
  5. <el-form label-width="100px" style="display: flex; align-items: center;">
  6. <el-form-item style="text-align: center;margin: 0 0 0 -100px;">
  7. <el-button size="mini" type="primary" v-if="activeName=='basic' || activeName=='cloum'" @click="submitForm()">保存</el-button>
  8. <el-button size="mini" @click="close()">返回</el-button>
  9. </el-form-item>
  10. </el-form>
  11. </el-col>
  12. </el-row>
  13. <el-tabs v-model="activeName">
  14. <el-tab-pane label="基本信息" name="basic">
  15. <basic-info-form ref="basicInfo" :info="info" />
  16. </el-tab-pane>
  17. <el-tab-pane label="字段信息" name="cloum">
  18. <el-row type="flex" style="margin-bottom: 20px;" v-if="activeName=='cloum'" :gutter="10" justify="end">
  19. <el-col :span="1.5" style="display: flex; align-items: center;">
  20. <el-button style="background-color: #FFE9ED;color: #E58481;border: 1px solid #E58481;" type="warning" plain
  21. icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:post:add']">新增</el-button>
  22. </el-col>
  23. <el-col :span="1.5" style="display: flex; align-items: center;">
  24. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  25. v-hasPermi="['system:post:remove']" style="background-color: #FFD6B0;color: #EA551A;border: 1px solid #F4AD6B;">删除</el-button>
  26. </el-col>
  27. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
  28. </el-row>
  29. <el-table ref="dragTable" @row-dblclick="dbSelectedZd" align="center" :data="cloumns" row-key="columnId"
  30. :max-height="tableHeight" @selection-change="handleSelectionChange">
  31. <el-table-column type="selection" width="55" align="center" />
  32. <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" align="center" />
  33. <el-table-column label="字段列名" prop="columnName" min-width="10%" :show-overflow-tooltip="true" align="center" />
  34. <el-table-column label="字段描述" min-width="10%" align="center">
  35. <template slot-scope="scope">
  36. <el-input v-model="scope.row.columnComment"></el-input>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="物理类型" prop="columnType" align="center" min-width="10%" :show-overflow-tooltip="true" />
  40. <el-table-column label="字段显示规则" align="center" prop="mask" min-width="13%" />
  41. <el-table-column label="排序" min-width="8%" align="center" prop="sort" />
  42. <el-table-column label="输入字段" min-width="10%" align="center">
  43. <template slot-scope="scope">
  44. <el-checkbox true-label="Y" false-label="N" v-model="scope.row.isIn"></el-checkbox>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="显示字段" min-width="10%" align="center">
  48. <template slot-scope="scope">
  49. <el-checkbox true-label="Y" false-label="N" v-model="scope.row.isOut"></el-checkbox>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="查询" min-width="8%" align="center">
  53. <template slot-scope="scope">
  54. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isQuery"></el-checkbox>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="关联HR字段" min-width="13%" align="center" prop="hrParentId">
  58. <template slot-scope="scope">
  59. <div>
  60. {{scope.row.hrParentId | zdFn}}
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="缺省值" min-width="10%" align="center" prop="defaultValue" />
  65. <el-table-column label="外键" min-width="10%" align="center" prop="foreignKey">
  66. <template slot-scope="scope">
  67. <div>
  68. {{scope.row.foreignKey | zdFn}}
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="必填" min-width="8%" align="center">
  73. <template slot-scope="scope">
  74. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isRequired"></el-checkbox>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="显示类型" min-width="12%" align="center">
  78. <template slot-scope="scope">
  79. <el-select v-model="scope.row.htmlType">
  80. <el-option label="文本框" value="input" />
  81. <el-option label="文本域" value="textarea" />
  82. <el-option label="下拉框" value="select" />
  83. <el-option label="单选框" value="radio" />
  84. <el-option label="复选框" value="checkbox" />
  85. <el-option label="日期控件" value="datetime" />
  86. <el-option label="图片上传" value="imageUpload" />
  87. <el-option label="文件上传" value="fileUpload" />
  88. <el-option label="富文本控件" value="editor" />
  89. <el-option label="hr" value="hr" />
  90. </el-select>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="字典类型" min-width="12%" align="center">
  94. <template slot-scope="scope">
  95. <el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
  96. <el-option v-for="dict in dictOptions" :key="dict.dictType" :label="dict.dictName" :value="dict.dictType">
  97. <span style="float: left">{{ dict.dictName }}</span>
  98. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
  99. </el-option>
  100. </el-select>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <!-- 添加或修改岗位对话框 -->
  105. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="openZd" width="70vw" append-to-body>
  106. <el-form ref="formZd" :model="formZd" :rules="rulesZd" label-width="120px">
  107. <el-row>
  108. <el-col :span="8">
  109. <el-form-item label="字段名:" prop="columnName">
  110. <el-input :disabled="this.formZd.columnId" v-model="formZd.columnName" placeholder="请输入字段名" />
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="8">
  114. <el-form-item label="字段描述:" prop="columnComment">
  115. <el-input v-model="formZd.columnComment" placeholder="请输入字段描述" />
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="8">
  119. <el-form-item label="物理类型:" prop="columnType">
  120. <el-input v-model="formZd.columnType" placeholder="请输入物理类型" />
  121. </el-form-item>
  122. </el-col>
  123. </el-row>
  124. <el-row>
  125. <el-col :span="8">
  126. <el-form-item label="字段显示规则:" prop="mask">
  127. <el-input v-model="formZd.mask" placeholder="请输入字段显示规则" />
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="8">
  131. <el-form-item label="排序:" prop="sort">
  132. <el-input-number style="width: 100%;" v-model="formZd.sort" placeholder="请输入排序" />
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="8">
  136. <el-form-item label="正则表达式:" prop="regular">
  137. <el-input v-model="formZd.regular" placeholder="请输入正则表达式" />
  138. </el-form-item>
  139. </el-col>
  140. </el-row>
  141. <el-row>
  142. <el-col :span="8">
  143. <el-form-item label="外键(FK):" prop="foreignKey">
  144. <!-- <el-select style="width: 100%;" filterable v-model="formZd.foreignKey" placeholder="请选择外键(FK)" clearable size="small">
  145. <el-option v-for="dict in columList" :key="dict.columnId" :label="dict.columnName" :value="dict.columnId" />
  146. </el-select> -->
  147. <div style="cursor: pointer;" @click="fkzdFn">
  148. <el-input readonly style="width: 100%;" v-model="ForeName" placeholder="请选择外键(FK)" />
  149. </div>
  150. </el-form-item>
  151. </el-col>
  152. <el-col :span="8">
  153. <el-form-item label="关联HR字段:" prop="hrParentId">
  154. <el-select style="width: 100%;" v-model="formZd.hrParentId" placeholder="请选择关联HR字段" clearable>
  155. <el-option v-for="dict in columHRList" :key="dict.columnId" :label="dict.columnName" :value="dict.columnId" />
  156. </el-select>
  157. </el-form-item>
  158. </el-col>
  159. <el-col :span="8">
  160. <el-form-item label="缺省值:" prop="defaultValue">
  161. <el-input v-model="formZd.defaultValue" placeholder="请输入缺省值" />
  162. </el-form-item>
  163. </el-col>
  164. </el-row>
  165. <el-row>
  166. <el-col :span="8">
  167. <el-form-item label="行数:" prop="numRows">
  168. <el-input-number style="width: 100%;" v-model="formZd.numRows" placeholder="请输入行数" />
  169. </el-form-item>
  170. </el-col>
  171. <el-col :span="8">
  172. <el-form-item label="列数:" prop="numColumns">
  173. <el-input-number style="width: 100%;" v-model="formZd.numColumns" placeholder="请输入列数" />
  174. </el-form-item>
  175. </el-col>
  176. <el-col :span="8">
  177. <el-form-item label="字段翻译器:" prop="fieldTranslator">
  178. <el-input v-model="formZd.fieldTranslator" placeholder="请输入字段翻译器" />
  179. </el-form-item>
  180. </el-col>
  181. </el-row>
  182. <el-row>
  183. <el-col :span="8">
  184. <el-form-item label="扩展属性:" prop="extendedAttributes">
  185. <el-input v-model="formZd.extendedAttributes" placeholder="请输入扩展属性" />
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="8">
  189. <el-form-item label="查询方式:" prop="queryType">
  190. <el-select style="width: 100%;" v-model="formZd.queryType">
  191. <el-option label="=" value="EQ" />
  192. <el-option label="!=" value="NE" />
  193. <el-option label=">" value="GT" />
  194. <el-option label=">=" value="GTE" />
  195. <el-option label="<" value="LT" />
  196. <el-option label="<=" value="LTE" />
  197. <el-option label="LIKE" value="LIKE" />
  198. <el-option label="BETWEEN" value="BETWEEN" />
  199. </el-select>
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="8">
  203. <el-form-item label="显示类型:" prop="htmlType">
  204. <el-select style="width: 100%;" v-model="formZd.htmlType">
  205. <el-option label="文本框" value="input" />
  206. <el-option label="文本域" value="textarea" />
  207. <el-option label="下拉框" value="select" />
  208. <el-option label="单选框" value="radio" />
  209. <el-option label="复选框" value="checkbox" />
  210. <el-option label="日期控件" value="datetime" />
  211. <el-option label="图片上传" value="imageUpload" />
  212. <el-option label="文件上传" value="fileUpload" />
  213. <el-option label="富文本控件" value="editor" />
  214. <el-option label="hr" value="hr" />
  215. </el-select>
  216. </el-form-item>
  217. </el-col>
  218. </el-row>
  219. <el-row>
  220. <el-col :span="8">
  221. <el-form-item label="字典类型:" prop="dictType">
  222. <template slot-scope="scope">
  223. <el-select style="width: 100%;" v-model="formZd.dictType" clearable filterable placeholder="请选择">
  224. <el-option v-for="dict in dictOptions" :key="dict.dictType" :label="dict.dictName" :value="dict.dictType">
  225. <span style="float: left">{{ dict.dictName }}</span>
  226. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
  227. </el-option>
  228. </el-select>
  229. </template>
  230. </el-form-item>
  231. </el-col>
  232. <el-col :span="8">
  233. <el-form-item label="显示字段" prop="isOut">
  234. <el-checkbox true-label="Y" false-label="N" v-model="formZd.isOut"></el-checkbox>
  235. </el-form-item>
  236. </el-col>
  237. <el-col :span="8">
  238. <el-form-item label="输入字段" prop="isIn">
  239. <el-checkbox true-label="Y" false-label="N" v-model="formZd.isIn"></el-checkbox>
  240. </el-form-item>
  241. </el-col>
  242. </el-row>
  243. <el-row>
  244. <el-col :span="8">
  245. <el-form-item label="查询条件" prop="isQuery">
  246. <el-checkbox true-label="1" false-label="0" v-model="formZd.isQuery"></el-checkbox>
  247. </el-form-item>
  248. </el-col>
  249. <el-col :span="8">
  250. <el-form-item label="必填" prop="isRequired">
  251. <el-checkbox true-label="1" false-label="0" v-model="formZd.isRequired"></el-checkbox>
  252. </el-form-item>
  253. </el-col>
  254. </el-row>
  255. </el-form>
  256. <div slot="footer" class="dialog-footer">
  257. <el-button type="primary" @click="submitFormZd">确 定</el-button>
  258. <el-button @click="cancel">取 消</el-button>
  259. </div>
  260. </el-dialog>
  261. </el-tab-pane>
  262. <!-- <el-tab-pane label="生成信息" name="genInfo">
  263. <gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
  264. </el-tab-pane> -->
  265. <el-tab-pane label="关联表" name="genInfo">
  266. <el-row style="margin-bottom: 20px;" type="flex" :gutter="10" justify="end">
  267. <el-col :span="1.5">
  268. <el-button @click="handleAdd_gl" icon="el-icon-plus" size="mini" style="background-color: #FFE9ED;color: #E58481;border: 1px solid #E58481;">新增</el-button>
  269. </el-col>
  270. <el-col :span="1.5">
  271. <el-button icon="el-icon-delete" @click="handleDel_gl" size="mini" style="background-color: #FFD6B0;color: #EA551A;border: 1px solid #F4AD6B;"
  272. :disabled="multiple1">删除</el-button>
  273. </el-col>
  274. </el-row>
  275. <el-table ref="dragTable" @row-dblclick="dbSelected" v-loading="loading" :data="postList" row-key="columnId"
  276. align="center" :max-height="tableHeight" @selection-change="handleSelectionChange1">
  277. <el-table-column type="selection" width="55" align="center" />
  278. <el-table-column label="id" width="60" align="center" prop="id" />
  279. <el-table-column label="可用" align="center" prop="isDel">
  280. <template slot-scope="scope">
  281. <el-checkbox true-label="Y" disabled false-label="N" v-model="scope.row.isDel"></el-checkbox>
  282. </template>
  283. </el-table-column>
  284. <el-table-column label="序号" align="center" prop="sort" />
  285. <el-table-column label="描述" align="center" prop="description" />
  286. <el-table-column label="关联表" align="center" prop="tableName" />
  287. <el-table-column label="字段(关联到主表PK)" width="160px" align="center" prop="columnName" />
  288. <el-table-column label="显示条件" align="center" prop="displayConditions" />
  289. <el-table-column label="关联方式" align="center" prop="relationType">
  290. <template slot-scope="scope">
  291. {{scope.row.relationType | relationTypeFn}}
  292. </template>
  293. </el-table-column>
  294. <el-table-column label="内嵌编辑" align="center" prop="embedEdit">
  295. <template slot-scope="scope">
  296. {{scope.row.embedEdit | embedEditFn}}
  297. </template>
  298. </el-table-column>
  299. <el-table-column label="修改人" align="center" prop="updateBy" />
  300. <el-table-column label="修改时间" align="center" prop="updateTime" />
  301. </el-table>
  302. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  303. @pagination="tabList" />
  304. </el-tab-pane>
  305. <el-tab-pane label="数据库SQL" name="genSql">
  306. <el-row type="flex" justify="end">
  307. <el-button @click="zxCreaBtn" size="mini" style="background-color: #FFE9ED;color: #E58481;border: 1px solid #E58481;">执行创建语句</el-button>
  308. <el-button @click="sxCreaBtn" size="mini" style="background-color: #FFD6B0;color: #EA551A;border: 1px solid #F4AD6B;">刷新创建语句</el-button>
  309. </el-row>
  310. <el-form>
  311. <el-form-item label="创建语句:" style="margin-top: 20px;">
  312. <el-input class="resizeNone" v-model="tableSqlData.createSql" type="textarea" />
  313. </el-form-item>
  314. <el-form-item label="修改日志:">
  315. <el-input class="resizeNone" v-model="tableSqlData.createLog" type="textarea" />
  316. </el-form-item>
  317. </el-form>
  318. </el-tab-pane>
  319. </el-tabs>
  320. <!-- 添加或修改岗位对话框 -->
  321. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
  322. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  323. <el-form-item label="描述:" prop="postName">
  324. <el-input v-model="form.description" placeholder="请输入描述" />
  325. </el-form-item>
  326. <el-form-item label="关联表:" prop="relationParentId">
  327. <el-select style="width: 100%;" v-model="form.relationParentId" placeholder="请选择关联表" @change="relationFn"
  328. v-loadmore="loadMore">
  329. <el-option v-for="item in tableList.rows" :key="item.tableId" :label="item.tableComment" :value="item.tableId">
  330. </el-option>
  331. </el-select>
  332. </el-form-item>
  333. <el-form-item label="字段:" prop="relationChildId">
  334. <el-select style="width: 100%;" v-model="form.relationChildId" placeholder="请选择字段" v-loadmore="loadMore">
  335. <el-option v-for="item in genList" v-if="item.foreignKey" :key="item.columnId" :label="item.columnName" :value="item.columnId">
  336. </el-option>
  337. </el-select>
  338. </el-form-item>
  339. <el-form-item label="显示条件:" prop="displayConditions">
  340. <el-input v-model="form.displayConditions" controls-position="right" placeholder="请输入显示条件" />
  341. </el-form-item>
  342. <el-form-item label="关联方式:" prop="relationType">
  343. <el-select style="width: 100%;" v-model="form.relationType" placeholder="请选择关联方式" clearable size="small">
  344. <el-option v-for="dict in relationType" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
  345. </el-select>
  346. </el-form-item>
  347. <el-form-item label="内嵌编辑:" prop="embedEdit">
  348. <el-select style="width: 100%;" v-model="form.embedEdit" placeholder="岗位状态" clearable size="small">
  349. <el-option v-for="dict in embedEdit" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
  350. </el-select>
  351. </el-form-item>
  352. <el-form-item label="序号:" prop="sort">
  353. <el-input-number style="width: 100%;" v-model="form.sort" controls-position="right" :min="0" />
  354. </el-form-item>
  355. <el-form-item label="是否可用:" prop="isDel">
  356. <el-checkbox true-label="Y" false-label="N" v-model="form.isDel"></el-checkbox>
  357. </el-form-item>
  358. </el-form>
  359. <div slot="footer" class="dialog-footer">
  360. <el-button type="primary" @click="addGlfn">确 定</el-button>
  361. <el-button @click="cancel">取 消</el-button>
  362. </div>
  363. </el-dialog>
  364. <!-- 快速搜索对话框 -->
  365. <el-dialog :close-on-click-modal="false" :title="titleopenquery" :visible.sync="openquery" width="1200px" append-to-body>
  366. <el-form ref="formquery" @row-dblclick="dbSelectedZd" :model="formquery" :rules="rules" label-width="100px">
  367. <dynamic-forms :ref="item.columnName" :config="formquery.fixedData" @inputs = "changeFn" :formConfig="item" v-for="(item,index) in queryData.queryList" :key='index' />
  368. <el-form-item style="display: inline-block;">
  369. <el-button type="primary" @click="handleQuery">搜索</el-button>
  370. <el-button @click="openquery = false">取消</el-button>
  371. </el-form-item>
  372. </el-form>
  373. <el-table stripe @row-dblclick="tableBtn" :data="postListquery.rows" @selection-change="handleSelectionChange">
  374. <el-table-column :label="item.columnComment" align="center" :prop="item.columnName" v-for="(item,index) in postListquery.tableHeadList" :key="index" />
  375. </el-table>
  376. <pagination
  377. v-show="totalquery>0"
  378. :total="totalquery"
  379. :page.sync="aliemg.pageNo"
  380. :limit.sync="aliemg.pageSize"
  381. @pagination="getLisail"
  382. />
  383. </el-dialog>
  384. </el-card>
  385. </template>
  386. <script>
  387. import {
  388. getGenTable,
  389. updateGenTable,
  390. delPost,
  391. tabList,
  392. listTable,
  393. addGenTable,
  394. setGenTable,
  395. delGenTable,
  396. listAllColumnsByTableId,
  397. genTableColumnList,
  398. tableSql,
  399. zxImplement,
  400. getReload,
  401. addGenTableColumn,
  402. delGenTableColumn,
  403. setGenTableColumn,
  404. getGenTableColumn,
  405. getByIdWithForeignKey,
  406. listIndexfou,
  407. tableQuery,
  408. qurGenTable
  409. } from "@/api/tool/gen";
  410. import {
  411. optionselect as getDictOptionselect
  412. } from "@/api/system/dict/type";
  413. import {
  414. listMenu as getMenuTreeselect
  415. } from "@/api/system/menu";
  416. import basicInfoForm from "./basicInfoForm";
  417. import genInfoForm from "./genInfoForm";
  418. import Sortable from 'sortablejs'
  419. let _this = ''
  420. export default {
  421. name: "GenEdit",
  422. components: {
  423. basicInfoForm,
  424. genInfoForm
  425. },
  426. data() {
  427. _this = this
  428. return {
  429. ForeName: '',
  430. totalquery:0,
  431. // 多行查询
  432. titleopenquery:'快速查询',
  433. // 获取输入框的参数
  434. queryLisr:{
  435. table:'gen_table_column'
  436. },
  437. aliemg:{
  438. table:'gen_table_column',
  439. orderBy:'create_time desc',
  440. pageNo:1,
  441. pageSize:10,
  442. fixedData:{
  443. condition:''
  444. }
  445. },
  446. postListquery:{},
  447. queryData: {},
  448. openquery:false,
  449. formquery:{},
  450. // 字段信息
  451. tableSqlData: [],
  452. columList: [],
  453. columHRList: [],
  454. foreignKey: [],
  455. openZd: false,
  456. formZd: {
  457. columnId: ''
  458. },
  459. rulesZd: {
  460. columnName: [{
  461. required: true,
  462. message: "请输入字段名",
  463. trigger: "blur"
  464. }],
  465. columnComment: [{
  466. required: true,
  467. message: "请输入字段描述",
  468. trigger: "blur"
  469. }],
  470. columnType: [{
  471. required: true,
  472. message: "请输入物理类型",
  473. trigger: "blur"
  474. }],
  475. mask: [{
  476. required: true,
  477. message: "请输入字段显示规则",
  478. trigger: "blur"
  479. }],
  480. sort: [{
  481. required: true,
  482. message: "请输入序号",
  483. trigger: "blur"
  484. }],
  485. },
  486. loadingZd: '',
  487. // 关联表
  488. title: "",
  489. loading: false,
  490. open: false,
  491. form: {},
  492. rules: {
  493. relationParentId: [{
  494. required: true,
  495. message: "请选择关联表",
  496. trigger: "blur"
  497. }],
  498. relationChildId: [{
  499. required: true,
  500. message: "请选择字段",
  501. trigger: "blur"
  502. }],
  503. relationType: [{
  504. required: true,
  505. message: "请选择关联条件",
  506. trigger: "blur"
  507. }],
  508. },
  509. postList: [],
  510. total: 1,
  511. tableList: {},
  512. // 关联方式
  513. // 内嵌编辑
  514. genList: [],
  515. glbParams: {
  516. pageNum: 1,
  517. pageSize: 10,
  518. },
  519. // 关联表查询参数
  520. queryParams: {
  521. relationParentId: this.$route.params && this.$route.params.tableId,
  522. pageNum: 1,
  523. pageSize: 10,
  524. },
  525. // 选中选项卡的 name
  526. activeName: "basic",
  527. // 表格的高度
  528. tableHeight: document.documentElement.scrollHeight - 245 + "px",
  529. // 表信息
  530. tables: [],
  531. // 表列信息
  532. cloumns: [],
  533. // 字典信息
  534. dictOptions: [],
  535. // 菜单信息
  536. menus: [],
  537. // 表详细信息
  538. info: {},
  539. // 选中数组
  540. ids: [],
  541. ids1: [],
  542. // 非单个禁用
  543. single: true,
  544. single1: true,
  545. // 非多个禁用
  546. multiple: true,
  547. multiple1: true,
  548. // 关联方式
  549. relationType: [],
  550. // 内嵌编辑
  551. embedEdit: [],
  552. };
  553. },
  554. filters: {
  555. zdFn(data) {
  556. let is = ''
  557. for (let item of _this.columList) {
  558. if (item.columnId == data) {
  559. is = item.columnName
  560. }
  561. }
  562. return is
  563. },
  564. relationTypeFn(data) {
  565. let is = ''
  566. for (let item of _this.relationType) {
  567. if (item.dictValue == data) {
  568. is = item.dictLabel
  569. }
  570. }
  571. return is
  572. },
  573. embedEditFn(data) {
  574. let is = ''
  575. for (let item of _this.embedEdit) {
  576. if (item.dictValue == data) {
  577. is = item.dictLabel
  578. }
  579. }
  580. return is
  581. },
  582. },
  583. created() {
  584. const tableId = this.$route.params && this.$route.params.tableId;
  585. if (tableId) {
  586. // 获取表详细信息
  587. getGenTable(tableId).then(res => {
  588. this.cloumns = res.data.rows;
  589. this.info = res.data.info;
  590. this.tables = res.data.tables;
  591. });
  592. //查询数据库sql
  593. tableSql(tableId).then(res => {
  594. if (res.data) {
  595. this.tableSqlData = res.data
  596. }
  597. })
  598. /** 查询字典下拉列表 */
  599. getDictOptionselect().then(response => {
  600. this.dictOptions = response.data;
  601. });
  602. // 关联HR字段
  603. genTableColumnList({
  604. tableId,
  605. htmlType: 'HR'
  606. }).then(response => {
  607. this.columHRList = response.rows;
  608. });
  609. // 关联字段
  610. listAllColumnsByTableId({
  611. tableId
  612. }).then(response => {
  613. this.columList = response.data;
  614. });
  615. // 关联表数据
  616. listTable(this.glbParams).then(response => {
  617. this.tableList = response;
  618. });
  619. /** 查询菜单下拉列表 */
  620. // getMenuTreeselect().then(response => {
  621. // this.menus = this.handleTree(response.data, "menuId");
  622. // });
  623. // 关联方式
  624. this.getDicts("relation_type").then(response => {
  625. this.relationType = response.data;
  626. });
  627. // 内嵌编辑
  628. this.getDicts("embed_edit").then(response => {
  629. this.embedEdit = response.data;
  630. });
  631. }
  632. this.tabList()
  633. },
  634. methods: {
  635. tableBtn(row){
  636. this.openquery = false
  637. this.ForeName = row.column_name
  638. this.formZd.foreignKey = row.column_id
  639. },
  640. fkzdFn() {
  641. this.queryedit()
  642. this.getLisail()
  643. this.openquery = true
  644. },
  645. changeFn(obj) {
  646. console.log(obj)
  647. for(let key in obj){
  648. this.formquery.fixedData[key] = obj[key]
  649. }
  650. },
  651. // 快速查询
  652. queryedit(){
  653. this.loading = true;
  654. tableQuery(this.queryLisr).then(response => {
  655. let data = response.data
  656. this.queryData = data
  657. this.loading = false;
  658. })
  659. },
  660. handleQuery(){
  661. for(let item of this.queryData.queryList){
  662. if(item.htmlType == 'checkbox' || item.htmlType == 'imageUpload' || item.htmlType == 'fileUpload'){
  663. this.formquery[item.columnName] = this.$refs[item.columnName][0].config
  664. } else{
  665. this.formquery[item.columnName] = this.$refs[item.columnName][0].config[item.columnName]
  666. }
  667. }
  668. this.aliemg.fixedData.condition = this.formquery
  669. this.getLisail()
  670. },
  671. // 快速查询列表
  672. getLisail() {
  673. this.loading = true;
  674. listIndexfou(this.aliemg).then(response => {
  675. if(response.data){
  676. // this.tableDataalid = response.data.tableHeadList;
  677. this.postListquery = response.data
  678. this.postListquery.rows.filter(route => {
  679. if(route.table_id.name){
  680. route.table_id = route.table_id.name
  681. }
  682. })
  683. this.totalquery = response.data.total;
  684. }
  685. this.loading = false;
  686. }
  687. );
  688. },
  689. submitFormZd() {
  690. this.$refs["formZd"].validate(valid => {
  691. if (valid) {
  692. const tableId = this.$route.params && this.$route.params.tableId;
  693. this.formZd.tableId = tableId
  694. if (this.formZd.columnId != undefined) {
  695. setGenTableColumn(this.formZd).then(response => {
  696. this.msgSuccess("修改成功");
  697. this.openZd = false;
  698. // 获取表详细信息
  699. getGenTable(tableId).then(res => {
  700. this.cloumns = res.data.rows;
  701. this.info = res.data.info;
  702. this.tables = res.data.tables;
  703. });
  704. });
  705. } else {
  706. addGenTableColumn(this.formZd).then(response => {
  707. this.msgSuccess("新增成功");
  708. this.openZd = false;
  709. // 获取表详细信息
  710. getGenTable(tableId).then(res => {
  711. this.cloumns = res.data.rows;
  712. this.info = res.data.info;
  713. this.tables = res.data.tables;
  714. });
  715. });
  716. }
  717. }
  718. });
  719. },
  720. sxCreaBtn() {
  721. const tableId = this.$route.params && this.$route.params.tableId
  722. getReload({
  723. tableId,
  724. createSql: this.tableSqlData.createSql,
  725. createLog: this.tableSqlData.createLog,
  726. id: this.tableSqlData.id
  727. }).then(res => {
  728. this.msgSuccess('刷新成功')
  729. //查询数据库sql
  730. tableSql(tableId).then(res => {
  731. if (res.data) {
  732. this.tableSqlData = res.data
  733. }
  734. })
  735. })
  736. },
  737. zxCreaBtn() {
  738. const _this = this
  739. this.$confirm('是否确认执行创建语句?', "警告", {
  740. confirmButtonText: "确定",
  741. cancelButtonText: "取消",
  742. type: "warning"
  743. }).then(function() {
  744. return zxImplement({
  745. tableId: _this.$route.params && _this.$route.params.tableId,
  746. createSql: _this.tableSqlData.createSql,
  747. createLog: _this.tableSqlData.createLog,
  748. id: _this.tableSqlData.id
  749. })
  750. }).then(res => {
  751. _this.msgSuccess('执行成功')
  752. })
  753. },
  754. dbSelectedZd(row) {
  755. this.reset();
  756. const id = row.columnId
  757. getByIdWithForeignKey(id).then(response => {
  758. let data = response.data
  759. data.foreignKey = data.foreignKey ? data.foreignKey - 0 : ''
  760. this.formZd = data;
  761. console.log(data,8890)
  762. if(data.fkInfo){
  763. this.ForeName = data.fkInfo.value
  764. }
  765. this.openZd = true;
  766. this.title = "修改字段信息";
  767. });
  768. },
  769. dbSelected(row) {
  770. this.reset();
  771. const id = row.id
  772. qurGenTable(id).then(response => {
  773. let data = response.data
  774. data.relationType = data.relationType + ""
  775. data.embedEdit = data.embedEdit?(data.embedEdit + ""): data.embedEdit
  776. getGenTable(data.relationParentId).then(res => {
  777. this.genList = res.data.rows;
  778. this.form = data;
  779. this.open = true;
  780. this.title = "修改关联表";
  781. });
  782. });
  783. },
  784. addGlfn() {
  785. this.$refs["form"].validate(valid => {
  786. if (valid) {
  787. let datas = JSON.parse(JSON.stringify(this.form))
  788. datas.relationParentId = this.info.tableId
  789. if (this.form.id != undefined) {
  790. setGenTable(datas).then(response => {
  791. this.msgSuccess("修改成功");
  792. this.open = false;
  793. this.tabList();
  794. });
  795. } else {
  796. addGenTable(datas).then(response => {
  797. this.msgSuccess("新增成功");
  798. this.open = false;
  799. this.tabList();
  800. });
  801. }
  802. }
  803. });
  804. },
  805. relationFn(data) {
  806. getGenTable(data).then(res => {
  807. this.genList = res.data.rows;
  808. });
  809. },
  810. loadMore() {
  811. const _this = this
  812. let num = _this.tableList.total % 10 == 0 ? _this.tableList.total / 10 : ((_this.tableList.total - _this.tableList
  813. .total % 10) / 10 + 1)
  814. console.log(num, 1)
  815. if (this.glbParams.pageNum < num) {
  816. this.glbParams.pageNum++
  817. // 关联表数据
  818. listTable(this.glbParams).then(response => {
  819. let data = response
  820. data.rows = _this.tableList.rows.concat(data.rows)
  821. _this.tableList = data;
  822. });
  823. }
  824. },
  825. // 取消按钮
  826. cancel() {
  827. this.open = false;
  828. this.reset();
  829. this.openZd = false;
  830. this.resetZd();
  831. },
  832. // 关联表数据
  833. tabList() {
  834. this.loading = true;
  835. tabList(this.queryParams).then(response => {
  836. this.postList = response.rows;
  837. this.total = response.total;
  838. this.loading = false;
  839. });
  840. },
  841. /** 新增按钮操作 */
  842. handleAdd_gl() {
  843. this.reset();
  844. this.open = true;
  845. console.log(this.form)
  846. this.title = "新增关联表";
  847. },
  848. handleDel_gl(row) {
  849. const ids = row.id || this.ids1;
  850. console.log(ids, 1223)
  851. this.$confirm('是否确认删除id为"' + ids + '"的数据项?', "警告", {
  852. confirmButtonText: "确定",
  853. cancelButtonText: "取消",
  854. type: "warning"
  855. }).then(function() {
  856. return delGenTable(ids);
  857. }).then(() => {
  858. this.tabList();
  859. this.msgSuccess("删除成功");
  860. })
  861. },
  862. // 表单重置
  863. reset() {
  864. this.form = {
  865. isDel: 'N'
  866. };
  867. this.resetForm("form");
  868. },
  869. resetZd() {
  870. this.formZd = {
  871. columnId: ''
  872. };
  873. this.resetForm("formZd");
  874. },
  875. /** 提交按钮 */
  876. submitForm() {
  877. let isInFlag = 0
  878. let isOutFlag = 0
  879. console.log(this.cloumns,333)
  880. for(let item of this.cloumns){
  881. if(item.isIn=='Y'){
  882. isInFlag++
  883. }
  884. if(item.isOut=='Y'){
  885. isOutFlag++
  886. }
  887. }
  888. if(isInFlag>1){
  889. this.msgError('"输入字段"最多只能选择一个!')
  890. return
  891. }
  892. if(isOutFlag>1){
  893. this.msgError('"显示字段"最多只能选择一个!')
  894. return
  895. }
  896. const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
  897. // const genForm = this.$refs.genInfo.$refs.genInfoForm;
  898. Promise.all([basicForm].map(this.getFormPromise)).then(res => {
  899. const validateResult = res.every(item => !!item);
  900. if (validateResult) {
  901. const genTable = Object.assign({}, basicForm.model);
  902. genTable.columns = this.cloumns;
  903. // genTable.params = {
  904. // treeCode: genTable.treeCode,
  905. // treeName: genTable.treeName,
  906. // treeParentCode: genTable.treeParentCode,
  907. // parentMenuId: genTable.parentMenuId
  908. // };
  909. updateGenTable(genTable).then(res => {
  910. this.msgSuccess(res.msg);
  911. if (res.code === 200) {
  912. this.close();
  913. }
  914. });
  915. } else {
  916. this.msgError("表单校验未通过,请重新检查提交内容");
  917. }
  918. });
  919. },
  920. getFormPromise(form) {
  921. return new Promise(resolve => {
  922. form.validate(res => {
  923. resolve(res);
  924. });
  925. });
  926. },
  927. /** 关闭按钮 */
  928. close() {
  929. this.$store.dispatch("tagsView/delView", this.$route);
  930. this.$router.push({
  931. path: "/tool/gen",
  932. query: {
  933. t: Date.now()
  934. }
  935. })
  936. },
  937. // 多选框选中数据
  938. handleSelectionChange(selection) {
  939. this.ids = selection.map(item => item.columnId)
  940. this.single = selection.length != 1
  941. this.multiple = !selection.length
  942. },
  943. // 多选框选中数据
  944. handleSelectionChange1(selection) {
  945. this.ids1 = selection.map(item => item.id)
  946. this.single1 = selection.length != 1
  947. this.multiple1 = !selection.length
  948. },
  949. /** 删除按钮操作 */
  950. handleDelete(row) {
  951. const ids = row.id || this.ids;
  952. const tableId = this.$route.params && this.$route.params.tableId;
  953. this.$confirm('是否确认删除字段编号为"' + ids + '"的数据项?', "警告", {
  954. confirmButtonText: "确定",
  955. cancelButtonText: "取消",
  956. type: "warning"
  957. }).then(function() {
  958. return delGenTableColumn(ids);
  959. }).then(() => {
  960. // 获取表详细信息
  961. getGenTable(tableId).then(res => {
  962. this.cloumns = res.data.rows;
  963. this.info = res.data.info;
  964. this.tables = res.data.tables;
  965. });
  966. this.msgSuccess("删除成功");
  967. })
  968. },
  969. handleAdd() {
  970. this.resetZd();
  971. this.openZd = true;
  972. this.title = "新增字段信息";
  973. }
  974. },
  975. mounted() {
  976. const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0];
  977. const sortable = Sortable.create(el, {
  978. handle: ".allowDrag",
  979. onEnd: evt => {
  980. const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0];
  981. this.cloumns.splice(evt.newIndex, 0, targetRow);
  982. for (let index in this.cloumns) {
  983. this.cloumns[index].sort = parseInt(index) + 1;
  984. }
  985. }
  986. });
  987. }
  988. };
  989. </script>
  990. <style lang="scss">
  991. .pagination-container {
  992. height: 35px;
  993. }
  994. .resizeNone {
  995. width: 60vw;
  996. border-radius: 3px;
  997. .el-textarea__inner {
  998. //el_input中的隐藏属性
  999. resize: none; //主要是这个样式
  1000. height: 200px;
  1001. }
  1002. }
  1003. </style>