search.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="search-bar">
  3. <a-tabs v-model:activeKey="search.is_pubilc" @change="onSubmit">
  4. <a-tab-pane :key="1" tab="公共素材"></a-tab-pane>
  5. <a-tab-pane :key="0" tab="个人素材"></a-tab-pane>
  6. </a-tabs>
  7. <div class="search-item">
  8. <span class="label">{{
  9. type === "video" ? "视频名称:" : "图片名称:"
  10. }}</span>
  11. <a-input
  12. v-model:value="search.videoName"
  13. v-if="type === 'video'"
  14. placeholder="请输入"
  15. />
  16. <a-input
  17. v-model:value="search.imageName"
  18. v-if="type === 'picture'"
  19. placeholder="请输入"
  20. />
  21. </div>
  22. <div class="search-item">
  23. <span class="label">{{
  24. type === "video" ? "视频类型:" : "图片类型:"
  25. }}</span>
  26. <a-select
  27. placeholder="请选择"
  28. style="width: 200px"
  29. v-if="type === 'video'"
  30. v-model:value="search.videotype"
  31. >
  32. <a-select-option value="H">横板视频</a-select-option>
  33. <a-select-option value="S">竖板视频</a-select-option>
  34. </a-select>
  35. <a-select
  36. placeholder="请选择"
  37. style="width: 200px"
  38. v-if="type === 'picture'"
  39. v-model:value="search.imagetype"
  40. >
  41. <a-select-option value="H">横版大图</a-select-option>
  42. <a-select-option value="S">竖版大图</a-select-option>
  43. <a-select-option value="X">小图</a-select-option>
  44. </a-select>
  45. </div>
  46. <div class="search-item">
  47. <span class="label">推广书籍:</span>
  48. <a-select
  49. style="width: 200px"
  50. v-model:value="search.bookname"
  51. placeholder="请选择"
  52. >
  53. <a-select-option value="shanghai">Zone one</a-select-option>
  54. <a-select-option value="beijing">Zone two</a-select-option>
  55. </a-select>
  56. </div>
  57. <span class="flag" @click="openFlag = openFlag ? false : true"
  58. >{{ openFlag ? "收起" : "展开" }}
  59. <i v-if="openFlag" class="iconfont icon-shouqi"></i>
  60. <i v-else class="iconfont icon-zhankai"></i
  61. ></span>
  62. <div class="search-item" v-show="openFlag">
  63. <span class="label">需求方:</span>
  64. <a-input
  65. v-model:value="search.demander"
  66. type="text"
  67. placeholder="请输入"
  68. />
  69. </div>
  70. <div class="search-item" v-show="openFlag">
  71. <span class="label">文案:</span>
  72. <a-input v-model:value="search.editor" type="text" placeholder="请输入" />
  73. </div>
  74. <div class="search-item" v-show="openFlag">
  75. <span class="label">上传者:</span>
  76. <a-input
  77. v-model:value="search.uploader"
  78. type="text"
  79. placeholder="请输入"
  80. />
  81. </div>
  82. <div class="search-item">
  83. <span class="label"></span>
  84. <a-button type="primary" @click="onSubmit">搜索</a-button>
  85. <a-button style="margin-left: 10px" @click="reset">重置</a-button>
  86. </div>
  87. </div>
  88. </template>
  89. <script lang="ts">
  90. import { defineComponent, reactive, toRefs, ref } from "vue";
  91. import { message } from "ant-design-vue";
  92. const PictureLibrary = defineComponent({
  93. components: {},
  94. props: ["materialType"],
  95. setup(props) {
  96. const state = reactive({
  97. type: "", // 组件类型: video:picture
  98. openFlag: true, // 展开/收起
  99. search: {
  100. is_pubilc: 1, // 1公共素材 0个人素材
  101. videoName: "", // 视频名称
  102. videotype: "", // 视频类型
  103. imageName: "", // 图片名称
  104. imagetype: "", // 图片类型
  105. bookname: "", // 推广书籍
  106. demander: "", // 需求方
  107. editor: "", // 文案
  108. uploader: "", // 上传者
  109. },
  110. });
  111. return { ...toRefs(state) };
  112. },
  113. mounted() {
  114. console.log("TYPE", this.$props.materialType);
  115. this.type = this.$props.materialType;
  116. this.onSubmit();
  117. },
  118. methods: {
  119. // 搜索
  120. onSubmit() {
  121. console.log(this.search);
  122. let param: any = {
  123. is_pubilc: this.search.is_pubilc,
  124. book_name: this.search.bookname,
  125. demander: this.search.demander,
  126. editor: this.search.editor,
  127. uploader: this.search.uploader,
  128. };
  129. if (this.type === "video") {
  130. param.video_name = this.search.videoName;
  131. param.video_type = this.search.videotype;
  132. }
  133. if (this.type === "picture") {
  134. param.image_name = this.search.imageName;
  135. param.image_type = this.search.imagetype;
  136. }
  137. console.log("上传搜索条件", param);
  138. this.$emit("search", param);
  139. },
  140. // 重置
  141. reset() {
  142. this.search = {
  143. is_pubilc: this.search.is_pubilc, // 1公共素材 0个人素材
  144. videoName: "", // 视频名称
  145. videotype: "", // 视频类型
  146. imageName: "", // 图片名称
  147. imagetype: "", // 图片类型
  148. bookname: "", // 推广书籍
  149. demander: "", // 需求方
  150. editor: "", // 文案
  151. uploader: "", // 上传者
  152. };
  153. },
  154. },
  155. });
  156. export default PictureLibrary;
  157. </script>
  158. <style lang="scss" scoped>
  159. @import "@/assets/common-style/frame.scss";
  160. .search-bar {
  161. background: white;
  162. overflow: hidden;
  163. width: 100%;
  164. border-bottom: 1px solid rgb(204, 203, 203);
  165. .search-item {
  166. width: 25%;
  167. margin-left: 20px;
  168. float: left;
  169. display: flex;
  170. // justify-content: center;
  171. align-items: center;
  172. height: 50px;
  173. line-height: 50px;
  174. .label {
  175. width: 100px;
  176. height: 30px;
  177. line-height: 30px;
  178. display: block;
  179. text-align: right;
  180. }
  181. .ant-input,
  182. .ant-select-selector {
  183. width: 200px;
  184. }
  185. }
  186. .flag {
  187. display: inline-block;
  188. height: 50px;
  189. line-height: 50px;
  190. cursor: pointer;
  191. &:hover {
  192. color: rgb(6, 138, 190);
  193. }
  194. }
  195. }
  196. </style>