123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <!--
- * @FilePath: index.vue
- * @Author: 旭颖
- * @Date: 2023-05-31 16:51:34
- * @LastEditors: Please set LastEditors
- * @LastEditTime: 2023-06-13 18:06:16
- -->
- <template>
- <div>
- <el-select
- v-model="factory_id"
- clearable
- :disabled="disabled"
- filterable
- :loading="loading"
- placeholder="请输入招聘企业"
- remote
- :remote-method="remoteMethod"
- reserve-keyword
- style="width: 100%"
- @change="changeFactory"
- >
- <el-option
- v-for="item in companyList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </div>
- </template>
- <script>
- import { getFactoryList } from './api/index'
- export default defineComponent({
- name: 'BatchSend',
- props: {
- factory: {
- type: String,
- default: '',
- },
- disabled: {
- type: Boolean,
- default: false,
- },
- },
- emits: ['fetch-data'],
- setup(props, { emit }) {
- const state = reactive({
- companyList: [],
- factory_id: '', //工厂id
- loading: true,
- })
- watch(
- () => props.factory,
- () => {
- if (props.factory) {
- state.factory_id = props.factory
- } else {
- state.factory_id = ''
- }
- }
- )
- const remoteMethod = (e) => {
- factoryList(e)
- }
- const factoryList = async (e) => {
- state.loading = true
- const { data } = await getFactoryList({ s_name: e, status: 1 })
- const arr = []
- if (data && data.length > 0) {
- data.map((item) => {
- arr.push({
- id: item.id,
- name: '【' + item.s_name + '】' + item.name,
- s_name: item.s_name,
- })
- })
- }
- state.companyList = arr
- state.loading = false
- }
- //选择工厂
- const changeFactory = () => {
- let name = ''
- state.companyList.map((item) => {
- if (item.id == state.factory_id) {
- name = item.s_name
- }
- })
- emit('fetch-data', state.factory_id)
- emit('fetch-name', name)
- }
- onMounted(() => {
- factoryList()
- })
- return {
- ...toRefs(state),
- remoteMethod,
- factoryList,
- changeFactory,
- }
- },
- })
- </script>
|