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.

187 lines
5.5 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 v-if="" :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"></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">
  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 column = {
  122. "columnProp": item.trim(),
  123. "columnLabel": name,
  124. "columnHidden": false,
  125. "columnImage": false,
  126. "columnSortable": false,
  127. "columnWidth": null,
  128. "format": null,
  129. "sortLv": index,
  130. "status": true,
  131. "fixed": false,
  132. "serialNumber": null,
  133. "columnType": null,
  134. "align": null
  135. }
  136. this.columnList.push(column)
  137. })
  138. this.getDataList(true)
  139. })
  140. this.dataListLoading = false
  141. },
  142. getDataList(bool) {
  143. let sql = this.baseListData.sqlcode
  144. if (bool){
  145. sql += " and (" + this.baseListData.fieldname1 + " like '%" + this.param + "%' OR "+this.baseListData.fieldname2 + " like '%" + this.param + "%'" +" ) "
  146. }
  147. if (this.param1) {
  148. sql += " and " + this.baseListData.fieldname1 + " like '%" + this.param1 + "%'"
  149. }
  150. if (this.param2) {
  151. sql += " and " + this.baseListData.fieldname2 + " like '%" + this.param2 + "%'"
  152. }
  153. if (this.param3) {
  154. sql += " and active like '%" + this.param3 + "%'"
  155. }
  156. if (this.baseListData.caption4) {
  157. sql += " and site=" + this.param4
  158. }
  159. getChooselistData({"sqlcode": sql}).then(({data}) => {
  160. if (data.code == 0) {
  161. this.dataList = data.baseListData;
  162. } else {
  163. this.$message.error(data.msg)
  164. }
  165. })
  166. },
  167. getRowData(row) {
  168. this.visible = false
  169. this.$emit('getBaseData',row)
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. </style>