wupengfei
6 小时以前 45383d3d3c35934e1986d89bf695afde04ba7d2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<template>
  <ProDialog title="新增任务" v-model="visible" width="1200px" destroy-on-close>
    <ProTableQueryFilterBar>
      <template #query>
        <QueryFilterItem>
          <SearchInput
            v-model="extraParamState.keywords"
            style="width: 260px"
            placeholder="任务名/任务单号"
            @on-click-search="getList"
          >
          </SearchInput>
        </QueryFilterItem>
      </template>
    </ProTableQueryFilterBar>
    <ProTableV2
      v-bind="proTableProps"
      :columns="column"
      :operation-btns="operationBtns"
      :auto-height="false"
      :table-props="{
        height: '400px',
      }"
    >
    </ProTableV2>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('onCancel')">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确认</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import {
  ProDialog,
  useTable,
  defineColumns,
  ProTableV2,
  defineOperationBtns,
  ProTableQueryFilterBar,
  QueryFilterItem,
  SearchInput,
} from '@bole-core/components';
import * as taskUserServices from '@/services/api/taskUser';
 
defineOptions({
  name: 'AddTaskDialog',
});
 
type Form = {
  id: string;
};
 
const form = defineModel<Form>('form');
const visible = defineModel<boolean>('modelValue');
const selectedIds = ref<string[]>([]);
 
const emit = defineEmits<{
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
const operationBtns = defineOperationBtns([
  {
    data: {
      enCode: 'chooseBtn',
      name: '选择',
    },
    emits: {
      onClick: (role) => handleChoose(role),
    },
    extraProps: {
      hide: (row) => selectedIds.value.includes(row.id),
    },
  },
  {
    data: {
      enCode: 'cancelChooseBtn',
      name: '取消选择',
    },
    emits: {
      onClick: (role) => handleCancelChoose(role),
    },
    extraProps: {
      hide: (row) => !selectedIds.value.includes(row.id),
    },
  },
]);
 
const column = defineColumns([
  {
    id: '1',
    enCode: 'name',
    name: '任务名',
  },
  {
    id: '2',
    enCode: 'code',
    name: '任务单号',
  },
  {
    id: '3',
    enCode: 'enterpriseName',
    name: '发单客户',
  },
  {
    id: '4',
    enCode: 'enterpriseId',
    name: '客户ID',
  },
  {
    id: '5',
    enCode: 'beginTime',
    name: '任务开始',
  },
  {
    id: '6',
    enCode: 'endTime',
    name: '任务结束',
  },
]);
 
watch(
  () => visible.value,
  (value) => {
    if (value) {
      getList();
    }
  }
);
 
const {
  getDataSource: getList,
  proTableProps,
  paginationState,
  extraParamState,
} = useTable(
  async ({ pageIndex, pageSize }, extraParamState) => {
    try {
      let params: API.GetWaitArrangeTasksQuery = {
        pageModel: {
          rows: pageSize,
          page: pageIndex,
          orderInput: extraParamState.orderInput,
        },
        enterpriseEmployeeId: form.value.id,
        keywords: extraParamState.keywords,
      };
      let res = await taskUserServices.getWaitArrangeTasks(params);
      return res;
    } catch (error) {}
  },
  {
    defaultExtraParams: {
      keywords: '',
      orderInput: [{ property: 'id', order: EnumPagedListOrder.Desc }],
    },
    columnsRenderProps: {
      beginTime: { type: 'date' },
      endTime: { type: 'date' },
    },
  }
);
 
function handleChoose(row: API.GetWaitArrangeTasksQueryResultItem) {
  selectedIds.value.push(row.id);
}
 
function handleCancelChoose(row: API.GetWaitArrangeTasksQueryResultItem) {
  selectedIds.value = selectedIds.value.filter((id) => id !== row.id);
}
 
function handleConfirm() {
  emit('onConfirm');
}
</script>
 
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
</style>