|
@@ -4,24 +4,26 @@
|
|
|
<div style="margin-left: 20px; margin-right: 20px">
|
|
|
<e-desc title="基本信息" column="3">
|
|
|
<e-desc-item label="方案编码">{{ dataForm.optionCode }}</e-desc-item>
|
|
|
- <e-desc-item label="物料名称">{{ dataForm.materialName }}</e-desc-item>
|
|
|
+ <e-desc-item label="物料名称">{{ dataForm.productName }}</e-desc-item>
|
|
|
<e-desc-item label="方案名称">{{ dataForm.optionName }}</e-desc-item>
|
|
|
<e-desc-item label="备注说明" span="3">{{
|
|
|
dataForm.remark
|
|
|
}}</e-desc-item>
|
|
|
</e-desc>
|
|
|
<e-desc title="附件">
|
|
|
- <upload-component
|
|
|
- :display="true"
|
|
|
- :display-title="false"
|
|
|
- :accept="'*'"
|
|
|
- :file-obj-list="fileList"
|
|
|
- />
|
|
|
+ <e-desc-item span="2" label="附件">
|
|
|
+ <div v-for="(item, index) in dataForm.attachList" style="display: inline">
|
|
|
+ <span v-if="index > 0">,</span>
|
|
|
+ <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
|
|
|
+ </div>
|
|
|
+ </e-desc-item>
|
|
|
</e-desc>
|
|
|
</div>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="onChose">返回</el-button>
|
|
|
</span>
|
|
|
+ <!-- 文件预览 -->
|
|
|
+ <preview-component v-if="previewVisible" ref="preview"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -29,61 +31,30 @@
|
|
|
import EDesc from '../common/e-desc'
|
|
|
import EDescItem from '../common/e-desc-item'
|
|
|
import UploadComponent from '../common/upload-component'
|
|
|
-import { getMaterialList, getMaterialTechDetail } from '@/api/material'
|
|
|
+import { getMaterialTechDetail } from '@/api/material'
|
|
|
+import PreviewComponent from '@/views/modules/common/preview-component'
|
|
|
export default {
|
|
|
name: 'material-tech-detail',
|
|
|
- components: { UploadComponent, EDesc, EDescItem },
|
|
|
+ components: { PreviewComponent, UploadComponent, EDesc, EDescItem },
|
|
|
data () {
|
|
|
return {
|
|
|
id: 0,
|
|
|
isEdit: false,
|
|
|
- dataForm: {
|
|
|
- optionCode: '',
|
|
|
- productId: '',
|
|
|
- optionName: '',
|
|
|
- remark: ''
|
|
|
- },
|
|
|
- fileList: [],
|
|
|
- materialList: [],
|
|
|
- dataRule: {
|
|
|
- optionCode: [
|
|
|
- { required: true, message: '请输入方案编码', trigger: 'blur' }
|
|
|
- ],
|
|
|
- materialName: [
|
|
|
- { required: true, message: '请输入物料名称', trigger: 'blur' }
|
|
|
- ],
|
|
|
- optionName: [
|
|
|
- { required: true, message: '请输入方案名称', trigger: 'blur' }
|
|
|
- ]
|
|
|
- }
|
|
|
+ previewVisible: false,
|
|
|
+ dataForm: { }
|
|
|
}
|
|
|
},
|
|
|
- created () {},
|
|
|
methods: {
|
|
|
onChose () {
|
|
|
this.$emit('onChose')
|
|
|
},
|
|
|
- async init (id, display) {
|
|
|
+ async init (id) {
|
|
|
this.id = id || 0
|
|
|
- this.fileList = []
|
|
|
- this.materialList = []
|
|
|
-
|
|
|
- await this.getMaterialList()
|
|
|
-
|
|
|
if (!id) return
|
|
|
|
|
|
await getMaterialTechDetail(id).then(({ data }) => {
|
|
|
if (data && data.code === '200') {
|
|
|
- this.dataForm.productId = data.data.productId
|
|
|
- let marterial = this.materialList.find(
|
|
|
- (t) => t.materialId === data.data.productId
|
|
|
- )
|
|
|
- if (marterial) {
|
|
|
- this.dataForm.materialName = marterial.materialName
|
|
|
- }
|
|
|
- this.dataForm.optionCode = data.data.optionCode
|
|
|
- this.dataForm.optionName = data.data.optionName
|
|
|
- this.dataForm.remark = data.data.remark
|
|
|
+ this.dataForm = data.data
|
|
|
|
|
|
// 附件
|
|
|
if (data.data.attachList) {
|
|
@@ -98,55 +69,11 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- async getMaterialList () {
|
|
|
- await getMaterialList().then(({ data }) => {
|
|
|
- if (data && data.code === '200') {
|
|
|
- this.materialList = data.data.records
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- dataFormSubmit () {
|
|
|
- this.$refs['dataForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- // 物料技术文件
|
|
|
- let fList = this.fileList
|
|
|
- if (fList.length > 0) {
|
|
|
- this.dataForm.attachList = []
|
|
|
- for (let i = 0; i < fList.length; i++) {
|
|
|
- this.dataForm.attachList.push({
|
|
|
- fileName: fList[i].name,
|
|
|
- url: fList[i].url
|
|
|
- })
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.error('请上传工艺方案附件')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- this.$http({
|
|
|
- url: !this.id
|
|
|
- ? this.$http.adornUrl(`/biz-service/pro-technology-option/save`)
|
|
|
- : this.$http.adornUrl(
|
|
|
- `/biz-service/pro-technology-option/update`
|
|
|
- ),
|
|
|
- method: 'post',
|
|
|
- data: this.$http.adornData({ ...this.dataForm, orgId: this.orgId })
|
|
|
- }).then(({ data }) => {
|
|
|
- if (data && data.code === '200') {
|
|
|
- this.$message({
|
|
|
- message: '操作成功',
|
|
|
- type: 'success',
|
|
|
- duration: 1500,
|
|
|
- onClose: () => {
|
|
|
- this.onChose()
|
|
|
- this.$emit('refreshDataList')
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$message.error(data.msg)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ // 预览
|
|
|
+ previewFile (fileName, url) {
|
|
|
+ this.previewVisible = true
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.preview.init(fileName, url)
|
|
|
})
|
|
|
}
|
|
|
}
|