Search.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div class="wrapper">
  3. <span class="sqrk" @click="showModal">申请库({{ resNum }})</span>
  4. <span>
  5. <a-select ref="select" allowClear v-model:value="statusValue" style="width: 200px" :options="options"
  6. @change="onSearch">
  7. </a-select>
  8. </span>
  9. <span>
  10. <a-input-search allowClear v-model:value="keyWord" placeholder="请输入标题名称" style="width: 200px"
  11. @search="onSearch" />
  12. </span>
  13. <a-checkbox v-model:checked="checkAll" :indeterminate="indeterminate" @change="onCheckAllChange">
  14. 全部
  15. </a-checkbox>
  16. <div class="tagbox">
  17. <a-checkbox-group v-model:value="value4" :options="optionsTag" @change="tagChange"></a-checkbox-group>
  18. </div>
  19. <!-- 弹出框 -->
  20. <ResCarModal @register="registerModal" :type="props.type" @closeModal="visible = false" />
  21. </div>
  22. </template>
  23. <script>
  24. import { defineComponent, ref, computed, unref, getCurrentInstance, onMounted } from 'vue';
  25. import library from "../../../library/index.vue";
  26. import ResCarModal from './ResCarModal.vue';
  27. import { getResInCar, clearResInCar, tag } from '/@/api/resource/plat';
  28. import { session } from '/@/utils/Memory';
  29. import { message } from 'ant-design-vue';
  30. import { getAllTags } from '/@/api/sys/tag';
  31. import eventBus from '/@/utils/eventBus';
  32. import { useAdminStoreOut } from '/@/store/modules/admin';
  33. import { watch } from 'vue';
  34. import { useModal } from '/@/components/Modal';
  35. export default defineComponent({
  36. name: 'Search',
  37. components: { library, ResCarModal },
  38. props: {
  39. tag: {
  40. type: String,
  41. default: '',
  42. },
  43. type: {
  44. type: String,
  45. default: '',
  46. }
  47. },
  48. setup(props, { emit }) {
  49. const statusValue = ref('');
  50. const keyWord = ref('');
  51. const currentInstance = getCurrentInstance();
  52. const parentSetup = currentInstance.parent.setupState;
  53. const resNum = ref(0)
  54. const adminStore = useAdminStoreOut();
  55. // watch(() => adminStore.sqkList, (now, old) => {
  56. // console.log("sqkList:", old, now)
  57. // });
  58. //申请库旁边的数字
  59. onMounted(() => getResData())
  60. eventBus.on('addResToCarEventBus', () => getResData())
  61. const getResData = () => {
  62. getResInCar({
  63. userId: session.getItem('userId'),
  64. }).then((r) => {
  65. if (r.datas && r.datas.filter) {
  66. resNum.value = r.datas.filter(i => i.applyCarInfo.workflowType == props.type && i?.resInfo?.SERVICEID).length;
  67. }
  68. })
  69. }
  70. const options = ref([
  71. { value: '', label: '全部' },
  72. // { value: '未加入', label: '加入申请库' },
  73. { value: '未加入', label: '待申请' },
  74. { value: '已加入', label: '已加入申请库' },
  75. { value: '审核通过', label: '审核通过' },
  76. { value: '审核不通过', label: '审核不通过' },
  77. { value: '审核中', label: '审核中' },
  78. ]);
  79. function onSearch(key) {
  80. eventBus.emit('platListCenter', { sqkzt: statusValue.value, filterValue: keyWord.value, type: props.type, isPage: true });
  81. }
  82. const [registerModal, { openModal }] = useModal();
  83. const visible = ref(true);
  84. const showModal = () => {
  85. // visible.value = true;
  86. openModal(true, {
  87. isUpdate: false,
  88. isCheck:false,
  89. });
  90. };
  91. //标签加载
  92. const indeterminate = ref(true);
  93. const checkAll = ref(true);
  94. const value4 = ref([]);
  95. const optionsTag = ref([]);
  96. onMounted(() => getAllTags());
  97. function getAllTags() {
  98. tag().then((r) => r.map(i => props.tag.includes(i.code) && optionsTag.value.push({ label: i.name, value: i.code }) && value4.value.push(i.code)))
  99. }
  100. eventBus.on("tagChangeTag", () => value4.value = []);
  101. function tagChange(e, type) {
  102. console.log("222:", e, type);
  103. indeterminate.value = !!e.length && e.length < optionsTag.value.length;
  104. checkAll.value = e.length === optionsTag.value.length;
  105. eventBus.emit('platListCenter', {
  106. sqkzt: statusValue.value,
  107. filterValue: keyWord.value,
  108. type: props.type,
  109. isPage: true,
  110. keywords: e.length && type == undefined ? e.toString() : !e.length && type == undefined ? 'keywords' : type ? '' : 'keywords',
  111. });
  112. }
  113. const onCheckAllChange = (e) => {
  114. value4.value = e.target.checked ? optionsTag.value.map(i => i.value) : [];
  115. indeterminate.value = !indeterminate.value;
  116. tagChange(value4.value, e.target.checked);
  117. };
  118. return {
  119. registerModal,
  120. onCheckAllChange,
  121. indeterminate,
  122. checkAll,
  123. props,
  124. tagChange,
  125. value4,
  126. optionsTag,
  127. resNum,
  128. visible,
  129. showModal,
  130. options,
  131. statusValue,
  132. keyWord,
  133. onSearch,
  134. getResData
  135. };
  136. },
  137. });
  138. </script>
  139. <style scoped lang="less">
  140. .tagbox {
  141. width: calc(100% - 650px);
  142. overflow-x: auto;
  143. white-space: nowrap;
  144. overflow-y: hidden;
  145. }
  146. .wrapper>div {
  147. float: right;
  148. height: 32px;
  149. padding: 5px 0;
  150. }
  151. .wrapper>span {
  152. display: inline-block;
  153. margin-right: 30px
  154. }
  155. .wrapper {
  156. width: 100%;
  157. height: 54px;
  158. border-radius: 4px;
  159. background: #f8f8f8;
  160. padding: 11px;
  161. margin-bottom: 20px;
  162. }
  163. .sqrk {
  164. cursor: pointer;
  165. width: 94px;
  166. height: 32px;
  167. background: #0671DD;
  168. color: #fff;
  169. line-height: 32px;
  170. display: block;
  171. text-align: center;
  172. border-radius: 4px;
  173. }
  174. </style>