feat: adjust add task
This commit is contained in:
@@ -24,10 +24,8 @@
|
|||||||
<div class="ins-area">
|
<div class="ins-area">
|
||||||
|
|
||||||
<div class="ins-add">
|
<div class="ins-add">
|
||||||
<el-input v-model="searchWayID" placeholder="请输入要添加的渠道id" size="small" @change="searchID"
|
<el-autocomplete v-model="currSearchInputText" size="small" :fetch-suggestions="querySearchWayAsync"
|
||||||
class="searchInput"></el-input>
|
placeholder="请输入渠道名进行搜索" @select="handleSearchSelect" :clearable="true" value-key="name" />
|
||||||
<el-button @click="searchID()" size="small" type="primary" style="margin-left: 20px;">查询</el-button>
|
|
||||||
|
|
||||||
<div class="store-area" v-if="isShowAddBox">
|
<div class="store-area" v-if="isShowAddBox">
|
||||||
|
|
||||||
<div class="display-label">
|
<div class="display-label">
|
||||||
@@ -96,7 +94,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { defineComponent, onMounted, watch, reactive, toRefs, computed } from 'vue';
|
import { defineComponent, onMounted, watch, reactive, toRefs } from 'vue';
|
||||||
import { _ } from 'lodash';
|
import { _ } from 'lodash';
|
||||||
import { QuestionFilled } from '@element-plus/icons-vue'
|
import { QuestionFilled } from '@element-plus/icons-vue'
|
||||||
import { usePageState } from '@/store/page_sate.js';
|
import { usePageState } from '@/store/page_sate.js';
|
||||||
@@ -120,6 +118,8 @@ export default defineComponent({
|
|||||||
const pageState = usePageState();
|
const pageState = usePageState();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
insTableData: [],
|
insTableData: [],
|
||||||
|
currSearchWaysData: [],
|
||||||
|
currSearchInputText: '',
|
||||||
isShow: false,
|
isShow: false,
|
||||||
isShowAddBox: false,
|
isShowAddBox: false,
|
||||||
searchWayID: '',
|
searchWayID: '',
|
||||||
@@ -193,15 +193,38 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchID = async () => {
|
|
||||||
const rsp = await request.get('/sendways/get', { params: { id: state.searchWayID } });
|
// 匹配出当前搜索的渠道数据
|
||||||
let data = await rsp.data;
|
const matchSearchData = (way_name) => {
|
||||||
state.isShowAddBox = Boolean(data.data);
|
let result = {};
|
||||||
if (data.data) {
|
state.currSearchWaysData.forEach(element => {
|
||||||
state.currWayTmp = data.data;
|
if (element.name == way_name) {
|
||||||
|
result = element;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSearchSelect = async () => {
|
||||||
|
let currWay = matchSearchData(state.currSearchInputText)
|
||||||
|
state.isShowAddBox = Boolean(currWay);
|
||||||
|
if (currWay) {
|
||||||
|
state.currWayTmp = currWay;
|
||||||
|
// 初始化currInsInput
|
||||||
|
CONSTANT.WAYS_DATA_MAP[currWay.type].taskInsInputs.forEach(element => {
|
||||||
|
state.currInsInput[element.col] = ""
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const querySearchWayAsync = async (query, cb) => {
|
||||||
|
let params = { name: query };
|
||||||
|
const rsp = await request.get('/sendways/list', { params: params });
|
||||||
|
let tableData = await rsp.data.data.lists;
|
||||||
|
cb(tableData);
|
||||||
|
state.currSearchWaysData = tableData;
|
||||||
|
}
|
||||||
|
|
||||||
const getFinalData = () => {
|
const getFinalData = () => {
|
||||||
let postData = {
|
let postData = {
|
||||||
id: generateBizUniqueID('I'),
|
id: generateBizUniqueID('I'),
|
||||||
@@ -221,7 +244,7 @@ export default defineComponent({
|
|||||||
const rsp = await request.post('/sendtasks/ins/addone', postData);
|
const rsp = await request.post('/sendtasks/ins/addone', postData);
|
||||||
if (await rsp.data.code == 200) {
|
if (await rsp.data.code == 200) {
|
||||||
postData.enable = true;
|
postData.enable = true;
|
||||||
state.insTableData.push(postData);
|
state.insTableData.unshift(postData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +268,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...toRefs(state), handleCancer, handleAddSubmit, handleEditTask, CONSTANT, CommonUtils,
|
...toRefs(state), handleCancer, handleAddSubmit, handleEditTask, CONSTANT, CommonUtils,
|
||||||
searchID, handleDelete, insRowStyle, updateInsEnableStatus
|
handleDelete, insRowStyle, updateInsEnableStatus, handleSearchSelect, querySearchWayAsync
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user