search.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!-- 搜索表单 -->
  2. <template>
  3. <el-form
  4. label-width="77px"
  5. class="ele-form-search"
  6. @keyup.enter.native="search"
  7. @submit.native.prevent
  8. >
  9. <el-row :gutter="15">
  10. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  11. <el-form-item label="车间编码:">
  12. <el-input clearable v-model="where.code" placeholder="请输入" />
  13. </el-form-item>
  14. </el-col>
  15. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  16. <el-form-item label="车间名称:">
  17. <el-input clearable v-model="where.name" placeholder="请输入" />
  18. </el-form-item>
  19. </el-col>
  20. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  21. <el-form-item label="所属公司:">
  22. <ele-tree-select
  23. clearable
  24. :data="options.groupId"
  25. v-model="where.groupId"
  26. valueKey="id"
  27. labelKey="name"
  28. placeholder="请选择"
  29. default-expand-all
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  34. <el-form-item label="所属工厂:">
  35. <el-select
  36. v-model="where.parentId"
  37. placeholder="请选择"
  38. style="width: 100%"
  39. clearable
  40. >
  41. <el-option
  42. v-for="item in options_factory"
  43. :key="item.id"
  44. :label="item.name"
  45. :value="item.id"
  46. >
  47. </el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  52. <el-form-item label="组织机构:">
  53. <auth-selection v-model="where.deptIds" style="width: 100%"></auth-selection>
  54. </el-form-item>
  55. </el-col>
  56. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
  57. <div class="ele-form-actions">
  58. <el-button
  59. type="primary"
  60. icon="el-icon-search"
  61. class="ele-btn-icon"
  62. @click="search"
  63. >
  64. 查询
  65. </el-button>
  66. <el-button @click="reset">重置</el-button>
  67. </div>
  68. </el-col>
  69. </el-row>
  70. </el-form>
  71. </template>
  72. <script>
  73. export default {
  74. props: {
  75. options_groupId: {
  76. type: Array,
  77. default() {
  78. return [];
  79. }
  80. },
  81. options_factory: {
  82. type: Array,
  83. default() {
  84. return [];
  85. }
  86. }
  87. },
  88. watch: {
  89. options_groupId(nval) {
  90. this.toTreeData(nval);
  91. }
  92. },
  93. data() {
  94. // 默认表单数据
  95. const defaultWhere = {
  96. code: '',
  97. name: '',
  98. groupId: '',
  99. parentId: ''
  100. };
  101. return {
  102. defaultWhere,
  103. // 表单数据
  104. where: { ...defaultWhere },
  105. options: {
  106. groupId: []
  107. }
  108. };
  109. },
  110. computed: {
  111. // 是否开启响应式布局
  112. styleResponsive() {
  113. return this.$store.state.theme.styleResponsive;
  114. }
  115. },
  116. methods: {
  117. /* 搜索 */
  118. search() {
  119. this.$emit('search', this.where);
  120. },
  121. /* 重置 */
  122. reset() {
  123. console.log(this.defaultWhere);
  124. this.where = { ...this.defaultWhere };
  125. this.search();
  126. },
  127. // 格式化公司数据
  128. toTreeData(val) {
  129. this.options.groupId = this.$util.toTreeData({
  130. data: val,
  131. idField: 'id',
  132. parentIdField: 'parentId'
  133. });
  134. }
  135. }
  136. };
  137. </script>