You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
5.8 KiB

  1. <template>
  2. <el-dialog :title="baseListData.description" center
  3. :close-on-click-modal="false" :show-close="false" :close-on-press-escape="false"
  4. :visible.sync="visible"
  5. width="685px" v-drag>
  6. <el-form label-position="top"
  7. inline="inline"
  8. size="mini"
  9. label-width="120px">
  10. <el-form-item :label="baseListData.caption1" v-if="baseListData.caption1!='' && baseListData.caption1!=null">
  11. <el-input v-model="param1"></el-input>
  12. </el-form-item>
  13. <el-form-item :label="baseListData.caption2" v-if="baseListData.caption2!='' && baseListData.caption2!=null">
  14. <el-input v-model="param2"></el-input>
  15. </el-form-item>
  16. <el-form-item :label="baseListData.caption4" v-if="baseListData.caption4!='' && baseListData.caption4!=null">
  17. <el-input v-model="param4" style="width: 120px"></el-input>
  18. </el-form-item>
  19. <el-form-item :label="baseListData.caption3" v-if="baseListData.caption3!='' && baseListData.caption3!=null">
  20. <el-select v-model="param3" style="width: 120px">
  21. <el-option label="全部" value=""></el-option>
  22. <el-option label="在用" value="Y"></el-option>
  23. <el-option label="不在用" value="N"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-button style="margin-top: 18px" type="primary" @click="getDataList(false)">查询
  27. </el-button>
  28. </el-form>
  29. <el-table
  30. :height="height"
  31. :data="dataList"
  32. border
  33. @row-dblclick="getRowData"
  34. v-loading="dataListLoading"
  35. style="width: 100%;">
  36. <el-table-column
  37. v-for="(item,index) in columnList" :key="index"
  38. :sortable="item.columnSortable"
  39. :prop="item.columnProp"
  40. :header-align="item.headerAlign"
  41. :show-overflow-tooltip="item.showOverflowTooltip"
  42. :align="item.align"
  43. :fixed="item.fixed"
  44. :min-width="item.columnWidth"
  45. :label="item.columnLabel">
  46. <template slot-scope="scope">
  47. {{ scope.row[item.columnProp] }}
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <span slot="footer" class="dialog-footer">
  52. <el-button @click="visible = false">关闭</el-button>
  53. </span>
  54. </el-dialog>
  55. </template>
  56. <script>
  57. import {
  58. getChooselist,
  59. getChooselistData
  60. } from "@/api/chooselist/chooselist.js"
  61. export default {
  62. data() {
  63. return {
  64. height: 200,
  65. title: '列表',
  66. columnList: [],
  67. queryTable: {},
  68. visible: false,
  69. dataListLoading: true,
  70. fullscreenLoading: false,
  71. param1: '',
  72. param2: '',
  73. param3: '',
  74. param: '',
  75. param4: this.$store.state.user.site,
  76. dataList: [],
  77. baseListData: {
  78. caption1: '',
  79. caption2: '',
  80. caption3: '',
  81. caption4: '',
  82. description: '',
  83. fieldname1: '',
  84. fieldname2: '',
  85. sqlcode: '',
  86. tagno: '',
  87. },
  88. defaultParam: false
  89. }
  90. },
  91. methods: {
  92. // 获取 用户的配置
  93. init(tagNo,param) {
  94. this.visible = true;
  95. this.param = param
  96. // 根据 tagNo 获取列表
  97. getChooselist({"tagNo": tagNo}).then(({data}) => {
  98. this.columnList = []
  99. this.baseListData = data.data
  100. let start = data.data.sqlcode.indexOf("Select")
  101. let end = data.data.sqlcode.indexOf("from")
  102. let length = end - start
  103. let columns = data.data.sqlcode.trim().substring(start + 6, length).trim()
  104. let props = columns.split(",")
  105. props.forEach((item, index) => {
  106. let name = '信息列'
  107. switch (index) {
  108. case 0:
  109. name = this.baseListData.caption1
  110. break;
  111. case 1:
  112. name = this.baseListData.caption2
  113. break;
  114. case 2:
  115. name = this.baseListData.caption3
  116. break;
  117. case 3:
  118. name = this.baseListData.caption4
  119. break;
  120. }
  121. let index1 = item.indexOf(" as ");
  122. let index2 = item.indexOf(".");
  123. let l = item.length
  124. let prop = item
  125. if (index1> 0){
  126. prop = item.substring(index1+3,l).trim()
  127. }
  128. if (index1<0 && index2>0){
  129. prop = item.substring(index2+1,l)
  130. }
  131. let column = {
  132. "columnProp":prop.trim(),
  133. "columnLabel": name,
  134. "columnHidden": false,
  135. "columnImage": false,
  136. "columnSortable": false,
  137. "columnWidth": null,
  138. "format": null,
  139. "sortLv": index,
  140. "status": true,
  141. "fixed": false,
  142. "serialNumber": null,
  143. "columnType": null,
  144. "align": null
  145. }
  146. this.columnList.push(column)
  147. })
  148. this.getDataList(true)
  149. })
  150. this.dataListLoading = false
  151. },
  152. getDataList(bool) {
  153. let sql = this.baseListData.sqlcode
  154. if (bool){
  155. sql += " and (" + this.baseListData.fieldname1 + " like '%" + this.param + "%' OR "+this.baseListData.fieldname2 + " like '%" + this.param + "%'" +" ) "
  156. }
  157. if (this.param1) {
  158. sql += " and " + this.baseListData.fieldname1 + " like '%" + this.param1 + "%'"
  159. }
  160. if (this.param2) {
  161. sql += " and " + this.baseListData.fieldname2 + " like '%" + this.param2 + "%'"
  162. }
  163. if (this.param3) {
  164. sql += " and active like '%" + this.param3 + "%'"
  165. }
  166. if (this.baseListData.caption4) {
  167. sql += " and site=" + this.param4
  168. }
  169. getChooselistData({"sqlcode": sql}).then(({data}) => {
  170. if (data.code == 0) {
  171. this.dataList = data.baseListData;
  172. } else {
  173. this.$message.error(data.msg)
  174. }
  175. })
  176. },
  177. getRowData(row) {
  178. this.visible = false
  179. this.$emit('getBaseData',row)
  180. }
  181. }
  182. }
  183. </script>
  184. <style>
  185. </style>