You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

382 lines
12 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<xy-dialog ref="dialog" :width="70" :is-show.sync="isShow" :type="'form'" :title="$route.meta.title" :form="form"
:rules='rules' @submit="submit">
<template v-slot:category_ids>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Product Phase
</div>
<div class="xy-table-item-content">
<el-select multiple collapse-tags filterable style="width:100%" v-model="form.category_ids"
placeholder="Please Select">
<el-option v-for="(item,index) in categoryList" :key="index" :label="item.name" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:year>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>Year
</div>
<div class="xy-table-item-content">
<el-date-picker style="width:100%" v-model="form.year" format="yyyy" value-format="yyyy" type="year"
placeholder="Please Select">
</el-date-picker>
</div>
</div>
</template>
<template v-slot:title>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>Title
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" style="width:100%" v-model="form.title"></el-input>
</div>
</div>
</template>
<template v-slot:source>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Source
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" style="width:100%" v-model="form.source"></el-input>
</div>
</div>
</template>
<template v-slot:date>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Release Time
</div>
<div class="xy-table-item-content">
<el-date-picker v-model="form.date" style="width:100%" format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="Please Select">
</el-date-picker>
</div>
</div>
</template>
<template v-slot:link>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Link
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" style="width:100%" v-model="form.link"></el-input>
</div>
</div>
</template>
<template v-slot:files>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>File
</div>
<div class="xy-table-item-content">
<el-upload :action="action" class='upload-demo' :limit="1" :file-list="filesList" ref="pictureUpload"
:auto-upload="true" :data="uploadOther" :on-success="handlesuccess" :on-remove="handleRemove">
<el-button size="small" type="primary">upload</el-button>
</el-upload>
</div>
</div>
</template>
<template v-slot:product_numbers>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>PN
</div>
<div class="xy-table-item-content">
<el-select style="width:100%" filterable v-model="form.product_numbers" multiple collapse-tags
placeholder="Please Select">
<el-option v-for="item in productList" :key="item.id" :label="item.number" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:separation_mode>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Separation Mode
</div>
<div class="xy-table-item-content">
<el-select style="width:100%" multiple filterable collapse-tags v-model="form.separation_mode"
placeholder="Please Select">
<el-option v-for="item in separationModeList" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:broad_sample_type>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Broad Sample Type
</div>
<div class="xy-table-item-content">
<el-select style="width:100%" multiple filterable collapse-tags v-model="form.broad_sample_type"
placeholder="Please Select">
<el-option v-for="item in applicationList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:specific_sample>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Specific Sample
</div>
<div class="xy-table-item-content">
<el-select style="width:100%" multiple filterable collapse-tags v-model="form.specific_sample"
placeholder="Please Select">
<el-option v-for="item in applicationList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show
} from "@/api/system/baseForm.js"
import resource from "@/mixin/resources.js"
import {
index as getCategory
} from "@/api/product/category.js"
import {
index as getApplication
} from "@/api/application/category.js"
import {
index as getProduct
} from "@/api/product/index.js"
import {
getToken
} from '@/utils/auth'
export default {
mixins: [resource],
data() {
return {
table_name: 'literature_references',
isShow: false,
id: '',
type: 'add',
productList: [],
categoryList: [],
applicationList: [],
appSpecialList: [],
uploadOther: {
token: ""
},
action: `${process.env.VUE_APP_UPLOAD_API}`,
filesList: [],
form: {
category_ids: [],
application_ids: [],
year: "",
title: "",
source: '',
date: '',
link: '',
files: [],
product_numbers: [],
separation_mode: [],
broad_sample_type: [],
specific_sample: [],
},
rules: {
year: [{
required: true,
message: 'Please Input'
}],
title: [{
required: true,
message: 'Please Input'
}],
// link: [{
// required: true,
// message: 'Please Input'
// }]
}
}
},
created() {
this.uploadOther.token = getToken();
this.getCategoryList()
// this.getProductList()
this.getApplicationList()
// this.getAppSpecial()
},
methods: {
handleRemove(file, fileList) {
this.filesList = fileList
},
handlesuccess(response, file, fileList) {
if (response && response.hasOwnProperty('errcode')) {
this.$Message.warning(response.errmsg || '')
this.filesList = []
return
}
this.filesList = fileList
},
async getCategoryList() {
const res = await getCategory({
page_size: 999,
page: 1,
sort_type: 'ASC',
sort_name: 'sort',
type: 2
})
this.categoryList = res.data
},
async getApplicationList() {
const res = await getApplication({
page_size: 9999,
page: 1,
sort_type: 'ASC',
sort_name: 'sort',
// filter:[{
// key:'type',
// op:'eq',
// value:0
// }]
})
this.applicationList = res.data
},
async getAppSpecial() {
const res = await getApplication({
page_size: 9999,
page: 1,
sort_type: 'ASC',
sort_name: 'sort',
filter: [{
key: 'type',
op: 'eq',
value: 1
}]
})
this.appSpecialList = res.data
},
async getProductList() {
const res = await getProduct({
page_size: 9999,
page: 1
})
this.productList = res.data
},
submit() {
if (this.id) {
this.form.id = this.id
} else {
this.form.id = ''
}
let _files = []
if (this.filesList.length > 0) {
for (var h of this.filesList) {
if (h.response) {
_files.push(h.response.id)
} else {
_files.push(h.id)
}
}
this.form.files = _files
} else {
this.form.files = []
}
console.log("this.form", this.form)
// return
save({
table_name: this.table_name,
...this.form
}).then(res => {
this.$message({
type: 'success',
message: 'Success'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
table_name: this.table_name,
id: this.id
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
this.form.date = res.date ? res.date : this.$moment().format('YYYY-MM-DD HH:mm:ss')
this.form.category_ids = res.category_ids ? res.category_ids : [],
this.form.product_numbers = res.product_numbers ? res.product_numbers : []
this.form.separation_mode = res.separation_mode ? res.separation_mode : []
this.form.broad_sample_type = res.broad_sample_type ? res.broad_sample_type : []
this.form.specific_sample = res.specific_sample ? res.specific_sample : []
if (res.files_details && res.files_details.length > 0) {
this.filesList = []
res.files_details.map(item => {
this.filesList.push({
name: item.original_name,
id: item.id,
url: item.url
})
})
}
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
} else {
this.form.date = this.$moment().format('YYYY-MM-DD HH:mm:ss')
}
} else {
this.id = ''
this.filesList = []
this.form = {
category_ids: [],
application_ids: [],
year: "",
title: "",
source: '',
date: '',
link: '',
files: [],
product_numbers: [],
separation_mode: [],
broad_sample_type: [],
specific_sample: [],
}
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .files{
flex-basis: 100%;
}
</style>