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.

248 lines
7.5 KiB

6 months ago
  1. <template>
  2. <div class="search">
  3. <el-dialog
  4. :close-on-click-modal="false"
  5. :show-close="false"
  6. :close-on-press-escape="false" title="查询条件"
  7. :visible.sync="visible"
  8. width="500px" v-drag>
  9. <el-table
  10. :height="height"
  11. :data="userColumnList"
  12. border
  13. style="width: 100%;">
  14. <el-table-column
  15. v-for="(item,index) in columnList" :key="index"
  16. :sortable="item.columnSortable"
  17. :prop="item.columnProp"
  18. :header-align="item.headerAlign"
  19. :show-overflow-tooltip="item.showOverflowTooltip"
  20. :align="item.align"
  21. :fixed="item.fixed==''?false:item.fixed"
  22. :min-width="item.columnWidth"
  23. :label="item.columnLabel">
  24. <template slot-scope="scope">
  25. <span v-if="item.columnProp == 'queryConditions'">
  26. <span v-if="scope.row.queryType=='date'">
  27. <el-select v-model="scope.row.queryConditions">
  28. <el-option value="=" label="="></el-option>
  29. </el-select>
  30. </span>
  31. <span v-if="scope.row.queryType=='number'">
  32. <el-select v-model="scope.row.queryConditions">
  33. <el-option value="=" label="="></el-option>
  34. </el-select>
  35. </span>
  36. <span v-if="scope.row.queryType=='string'">
  37. <el-select v-model="scope.row.queryConditions">
  38. <el-option value="=" label="="></el-option>
  39. <el-option value="like" label="like"></el-option>
  40. </el-select>
  41. </span>
  42. </span>
  43. <span v-else-if="item.columnProp == 'queryValue'">
  44. <span class="searchTime" v-if="scope.row.queryType=='date'">
  45. <el-date-picker value-format="yyyy-MM-dd" style="width: 100%" v-model="scope.row.queryValue" value="="></el-date-picker>
  46. </span>
  47. <span v-if="scope.row.queryType=='string'">
  48. <el-input style="width: 100%" v-model="scope.row.queryValue"></el-input>
  49. </span>
  50. <span v-if="scope.row.queryType=='number'">
  51. <el-input style="width: 100%" oninput ="value=value.replace(/[^0-9.]/g,'')" v-model="scope.row.queryValue"></el-input>
  52. </span>
  53. </span>
  54. <span v-else>
  55. {{ scope.row[item.columnProp] }}
  56. </span>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <span slot="footer" class="dialog-footer">
  61. <el-button type="primary" @click="searchCriteria()">搜索</el-button>
  62. <el-button @click="visible = false">关闭</el-button>
  63. </span>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import {
  69. getTableDefaultListLanguage,
  70. getTableUserListLanguage
  71. } from "@/api/table.js"
  72. export default {
  73. data() {
  74. return {
  75. height: 350,
  76. // 用户table 配置集合
  77. userColumnList: [],
  78. queryTable: {},
  79. visible: false,
  80. columnList: [
  81. {
  82. userId: this.$store.state.user.name,
  83. functionId: 9002,
  84. serialNumber: '9002SearchDescription',
  85. tableId: "9002Search",
  86. tableName: "搜索条件",
  87. columnProp: "queryDescription",
  88. headerAlign: "type",
  89. align: "left",
  90. columnLabel: "属性描述",
  91. columnHidden: false,
  92. columnImage: false,
  93. columnSortable: false,
  94. sortLv: 0,
  95. status: true,
  96. fixed: '',
  97. columnWidth: 80
  98. },
  99. // {
  100. // userId: this.$store.state.user.name,
  101. // functionId: 9002,
  102. // serialNumber: '9002SearchAttributes',
  103. // tableId: "9002Search",
  104. // tableName: "搜索条件",
  105. // columnProp: "queryAttributes",
  106. // headerAlign: "center",
  107. // align: "left",
  108. // columnLabel: "查询属性",
  109. // columnHidden: false,
  110. // columnImage: false,
  111. // columnSortable: false,
  112. // sortLv: 0,
  113. // status: true,
  114. // fixed: '',
  115. // columnWidth: 100
  116. // },
  117. // {
  118. // userId: this.$store.state.user.name,
  119. // functionId: 9002,
  120. // serialNumber: '9002SearchType',
  121. // tableId: "9002Search",
  122. // tableName: "搜索条件",
  123. // columnProp: "queryType",
  124. // headerAlign: "center",
  125. // align: "left",
  126. // columnLabel: "属性类型",
  127. // columnHidden: false,
  128. // columnImage: false,
  129. // columnSortable: false,
  130. // sortLv: 0,
  131. // status: true,
  132. // fixed: '',
  133. // columnWidth: 40
  134. // },
  135. // {
  136. // userId: this.$store.state.user.name,
  137. // functionId: 9002,
  138. // serialNumber: '9002SearchConditions',
  139. // tableId: "9002Search",
  140. // tableName: "搜索条件",
  141. // columnProp: "queryConditions",
  142. // headerAlign: "center",
  143. // align: "left",
  144. // columnLabel: "查询条件",
  145. // columnHidden: false,
  146. // columnImage: false,
  147. // columnSortable: false,
  148. // sortLv: 0,
  149. // status: true,
  150. // fixed: '',
  151. // columnWidth: 50
  152. // },
  153. {
  154. userId: this.$store.state.user.name,
  155. functionId: 9002,
  156. serialNumber: '9002SearchValue',
  157. tableId: "9002Search",
  158. tableName: "搜索条件",
  159. columnProp: "queryValue",
  160. headerAlign: "type",
  161. align: "left",
  162. columnLabel: "查询值",
  163. columnHidden: false,
  164. columnImage: false,
  165. columnSortable: false,
  166. columnWidth: 200,
  167. sortLv: 0,
  168. status: true,
  169. fixed: '',
  170. }
  171. ],
  172. }
  173. },
  174. methods: {
  175. // 确认搜索条件
  176. searchCriteria() {
  177. // const loading = this.$loading({
  178. // lock: true,
  179. // text: '查询中',
  180. // spinner: 'el-icon-loading',
  181. // background: 'rgba(0, 0, 0, 0.7)'
  182. // });
  183. var filter = this.userColumnList.filter(item => item.queryValue!="");
  184. this.$emit('childByValue', filter)
  185. setTimeout(() => {
  186. // loading.close();
  187. }, 2000);
  188. },
  189. // 获取 用户的配置
  190. init(queryTable) {
  191. this.queryTable = queryTable
  192. this.visible = true
  193. getTableUserListLanguage(queryTable).then(({data}) => {
  194. if (data.code == 0) {
  195. if (data.rows.length <= 0) {
  196. getTableDefaultListLanguage(queryTable).then(({data}) => {
  197. this.userColumnList = data.rows.map( item => {
  198. let data = {
  199. queryAttributes: item.columnProp,
  200. queryDescription: item.columnLabel,
  201. queryValue: '',
  202. queryConditions: '',
  203. queryType: item.columnType
  204. }
  205. return data
  206. })
  207. })
  208. }else {
  209. this.userColumnList = data.rows.map( item => {
  210. let data = {
  211. queryAttributes: item.columnProp,
  212. queryDescription: item.columnLabel,
  213. queryValue: '',
  214. queryConditions: '',
  215. queryType: item.columnType
  216. }
  217. return data
  218. })
  219. }
  220. }
  221. })
  222. },
  223. }
  224. }
  225. </script>
  226. <style lang="scss">
  227. .search .el-table .cell {
  228. height: 24px;
  229. }
  230. .search .el-input--medium .el-input__inner {
  231. height: 24px;
  232. line-height: 20px;
  233. }
  234. .el-input--medium .el-input__icon {
  235. line-height: 26px;
  236. }
  237. </style>