123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- import systemTask from "../task/components/index.vue"
- import FieldDrawer from '@/views/components/drawer/Field.vue'
- export default{
- components: {
- systemTask,
- FieldDrawer
- },
- props:{
- importData:{
- default:()=>{
- return {}
- }
- }
- },
- data() {
- return {
- tableData: [
- {
- name: '标引',
- field: 'index'
- }, {
- name: '分类',
- field: 'classify'
- }
- ],
- form:this.importData,
- customField: [],
- customFieldId:null,
- choseField:{},
- ExcelConfig:[],
- projectDetails:{},
- treeProp:{
- children:'child',
- label: 'name'
- },
- assoImportTaskFieldVOS:[],
- importContent:['0','1','2','3']
- }
- },
- computed:{
- importContents(){
- return this.$store.state.dictMessage.dictMessage.IMPORT_CONTENT
- }
- },
- mounted() {
- if(this.form.type == 1){
- this.getExcelConfig()
- }
- if(!this.form.importToId){
- return false
- }
- if(this.form.importToId && this.form.importToType != 2){
- //获取所有栏位
- this.getAllCustomField()
- }else{
-
- this.choseField = {
- id:this.form.importToId,
- name:this.form.name,
- type:6,
- isProduct:2,
- fieldValue:[]
- }
- this.customFieldId = this.form.importToId
- this.getProductTree()
- }
-
- },
- methods: {
- changeValue(value,data){
- if(this.choseField.type == 5 || this.choseField.type == 6){
- var index = this.assoImportTaskFieldVOS.findIndex(item=>{
- return item.fieldValueId == value
- })
- if(index!=-1){
- this.assoImportTaskFieldVOS.splice(index,1)
- }else{
- this.assoImportTaskFieldVOS.push(
- {
- projectId:this.form.importToId,
- fieldType:this.choseField.type,//类型
- fieldId:this.choseField.id,//栏位ID
- fieldValueId:value,
- keyValue:this.choseField.keyValue,
- fieldValueStr:data.name,
- fieldName:this.choseField.name
- }
- )
- }
- }else{
- var obj = this.assoImportTaskFieldVOS.find(item=>{
- return item.fieldId == this.choseField.id
- })
- if(obj){
- obj.fieldValueId = value
- }else{
- this.assoImportTaskFieldVOS.push(
- {
- projectId:this.form.importToId,
- fieldType:this.choseField.type,//类型
- fieldId:this.choseField.id,//栏位ID
- fieldValueId:value,
- keyValue:this.choseField.keyValue,
- fieldValueStr:data?data.name:value,
- fieldName:this.choseField.name
- }
- )
- }
- }
- },
- del(index,item){
- this.assoImportTaskFieldVOS.splice(index,1)
- var obj = this.customField.find(item=>{
- return item.keyValue == item.keyValue
- })
- if(obj){
- var index = obj.fieldValue.indexOf(item.fieldValueId)
- if(obj.type == 5 || obj.type == 6){
- obj.fieldValue.splice(index,1)
- }else{
- obj.fieldValue = ''
- }
- }
- },
- //修改选择的栏位
- changeCustomField(val){
- if(!val){
- return false
- }
- this.choseField = this.customField.find(item=>{
- return item.keyValue == val
- })
- if(this.choseField){
- if(this.choseField.options && this.choseField.options.length>0){
- return false
- }else{
- if(this.choseField.isProduct){
- this.getProductTree()
- }else{
- this.getFieldOption()
- }
- }
- }
- },
- //获取自定义选项
- getFieldOption(){
- let params = {
- customFieldId: this.choseField.id,
- }
- this.$api.queryCustomOption(params).then(response => {
- this.$set(this.choseField,'options',response.data.data)
- }).catch(error => {
- })
- },
- //获取产品架构
- getProductTree(){
- let params = {
- name: this.choseField.name,//名称
- type: this.choseField.isProduct,//类型:1产品类别,2产品,3技术分类,4自定义树
- typeId: this.choseField.id,//产品或类别id
- }
- this.$api.queryTreeNodeTree(params).then(res => {
- if (res.code == 200) {
- this.$set(this.choseField,'options',res.data.data)
- }
- }).catch(err => {
- })
- },
- //获取所有栏位
- async getAllCustomField(){
- const [project,product] = await Promise.allSettled([this.getProjectField(),this.getProjectDetails()])
- var projectField = project.status =='fulfilled'?project.value:[]
- this.projectDetails= product.status =='fulfilled'?product.value:{}
- if(this.ods){
- this.ods.data = [
- this.projectDetails
- ]
- this.$set(this.form,'importToId',this.form.importToId)
- }
- if(this.projectDetails.productOrCategory){
- projectField.push(
- {
- id:this.projectDetails.productOrCategory.id,
- name:this.projectDetails.productOrCategory.name,
- type:6,
- isProduct:this.projectDetails.productOrCategory.type,
- }
- )
- }
- projectField.forEach((item,index)=>{
- item.keyValue = (index+1)+''
- if(item.type == 5 || item.type == 6){
- this.$set(item,'fieldValue',[])
- }else{
- this.$set(item,'fieldValue','')
- }
- })
- this.customField =projectField
-
- },
- //获取自定义栏位
- async getProjectField(){
- var params = {
- searchQuery:`projectId=${this.form.importToId}`,
- orderDTOList: [
- {
- "orderBy": "type",
- "orderType": 1
- }
- ],
- }
- return await this.$api.queryCustomField(params).then( async response=>await response.data.data)
- },
- //获取项目信息
- async getProjectDetails(){
- if(this.form.importToType != 0){
- return {
- status:''
- }
- }
- var params = {
- searchQuery: `id=${this.form.importToId}`,//检索条件
- orderDTOList: [],//排序
- }
- return await this.$api.queryPatentProject(params).then( async response=>await response.data.data[0])
- },
-
- getExcelConfig() {
- this.$api.getExcelConfig().then(response => {
- this.ExcelConfig = response.data.data
- })
- },
- handleManage(){
- this.$refs.FieldDrawer.open(this.form.importToId)
- },
- closeFieldDrawer(){
- this.getAllCustomField()
- },
- //添加导入任务
- addImportTask(form){
- this.btnLoading = true
- this.loading = true
- this.$api.addImportTask(form).then(response => {
- this.$message.success('任务创建成功')
- this.form = this.importData
- this.btnLoading = false
- this.loading = false
- // this.getQueueList()
- this.getConfirm()
- }).catch(error => {
- this.btnLoading = false
- this.loading = false
- })
- },
- getQueueList() {
- this.$refs.systemTask.getList()
- },
- //弹窗
- getConfirm() {
- const h = this.$createElement;
- this.$msgbox({
- title: "提示",
- message: h("p", null, [
- h("span", null, "任务正在导入,查看任务进度请前往"),
- h(
- "span",
- {
- class: "MessageBoxClass",
- on: {
- click: () => {
- this.toTaskList();
- // 通过close关闭消息弹窗,this.$confirm就是this.$confirm.close(false),其他同理
- this.$msgbox.close(false);
- },
- },
- },
- "任务清单"
- ),
- ]),
- type: "warning",
- showConfirmButton: false,
- }).then((action) => {});
- },
- //跳转到任务清单
- toTaskList() {
- // 传专题库id是查到当前专题库的导入任务,不传是查看所有导入任务
- this.$router.push({
- path: "/taskList",
- query:{
- importToId:this.form.importToId
- }
- });
- },
- // 获取时间
- handleData(val) {
- if (this.form.dateType=='') {
- this.$message.error('请先选择更新周期')
- return false
- }
- this.form.crons=val
- },
- getDateType(val) {
- this.form.crons = ''
- },
- },
- }
|