|
@@ -1,13 +1,18 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <!-- <el-dialog
|
|
|
+ <div>
|
|
|
+ <!-- <el-dialog
|
|
|
:title="!id ? '新增': display ? '详情' : '修改'"
|
|
|
width="70%"
|
|
|
:close-on-click-modal="false"
|
|
|
:visible.sync="visible"> -->
|
|
|
- <div class="my-title">{{ !id ? '新增': display ? '详情' : '修改' }}</div>
|
|
|
- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
|
|
|
- <el-form-item label="图纸编码" prop="drawingCode">
|
|
|
+ <div class="my-title">{{ !id ? "新增" : display ? "详情" : "修改" }}</div>
|
|
|
+ <el-form
|
|
|
+ :model="dataForm"
|
|
|
+ :rules="dataRule"
|
|
|
+ ref="dataForm"
|
|
|
+ label-width="auto"
|
|
|
+ >
|
|
|
+ <!-- <el-form-item label="图纸编码" prop="drawingCode">
|
|
|
<el-input v-model="dataForm.drawingCode" :disabled="display || !id" placeholder="系统自动生成,无需填写"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="图纸名称" prop="drawingName">
|
|
@@ -18,137 +23,173 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="版本" prop="version">
|
|
|
<el-input v-model="dataForm.version" :disabled="display" placeholder="版本"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="图纸来源" prop="source">
|
|
|
- <el-input v-model="dataForm.source" :disabled="display" placeholder="图纸来源"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="备注" prop="notes">
|
|
|
- <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <upload-component :display="display" :title="'图纸'" :accept="'image/*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
|
|
|
- </el-form>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="onChose">取消</el-button>
|
|
|
- <el-button v-if="!display" type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
|
|
|
- </span>
|
|
|
- <!-- </el-dialog> -->
|
|
|
- </div>
|
|
|
+ </el-form-item> -->
|
|
|
+ <el-form-item label="图纸来源" prop="source">
|
|
|
+ <el-input
|
|
|
+ v-model="dataForm.source"
|
|
|
+ :disabled="display"
|
|
|
+ placeholder="图纸来源"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="notes">
|
|
|
+ <el-input
|
|
|
+ v-model="dataForm.notes"
|
|
|
+ :disabled="display"
|
|
|
+ placeholder="备注"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <upload-component
|
|
|
+ :display="display"
|
|
|
+ :title="'图纸'"
|
|
|
+ :accept="'image/*'"
|
|
|
+ :file-obj-list="fileList"
|
|
|
+ @uploadSuccess="uploadSuccess"
|
|
|
+ />
|
|
|
+ <div class="tip">
|
|
|
+ <span>命名要求:</span>
|
|
|
+ <span>图号(版本)图纸名称.xfdffg</span>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="onChose">取消</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="!display"
|
|
|
+ type="primary"
|
|
|
+ @click="dataFormSubmit()"
|
|
|
+ v-reClick
|
|
|
+ >确定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ <!-- </el-dialog> -->
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { getDrawingDetail } from '@/api/product'
|
|
|
- import UploadComponent from '../common/upload-component'
|
|
|
+import { getDrawingDetail } from '@/api/product'
|
|
|
+import UploadComponent from '../common/upload-component'
|
|
|
|
|
|
- export default {
|
|
|
- name: 'add-or-update',
|
|
|
- components: {UploadComponent},
|
|
|
- computed: {
|
|
|
- orgId: {
|
|
|
- get () { return this.$store.state.user.orgId }
|
|
|
+export default {
|
|
|
+ name: 'add-or-update',
|
|
|
+ components: { UploadComponent },
|
|
|
+ computed: {
|
|
|
+ orgId: {
|
|
|
+ get () {
|
|
|
+ return this.$store.state.user.orgId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // watch: {
|
|
|
+ // 'dataForm.isCompose' (value) {
|
|
|
+ // this.dataForm.displayProductList = value === '1'
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ display: false,
|
|
|
+ fileList: [],
|
|
|
+ dataList: [],
|
|
|
+ id: 0,
|
|
|
+ dataForm: {},
|
|
|
+ optionsProducts: [],
|
|
|
+ dataRule: {
|
|
|
+ drawingName: [
|
|
|
+ { required: true, message: '图纸名称不能为空', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ source: [
|
|
|
+ { required: true, message: '图纸来源不能为空', trigger: 'blur' }
|
|
|
+ ]
|
|
|
}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onChose () {
|
|
|
+ this.$emit('onChose')
|
|
|
},
|
|
|
- // watch: {
|
|
|
- // 'dataForm.isCompose' (value) {
|
|
|
- // this.dataForm.displayProductList = value === '1'
|
|
|
- // }
|
|
|
- // },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- visible: false,
|
|
|
- display: false,
|
|
|
- fileList: [],
|
|
|
- dataList: [],
|
|
|
- id: 0,
|
|
|
- dataForm: {},
|
|
|
- optionsProducts: [],
|
|
|
- dataRule: {
|
|
|
- drawingName: [{ required: true, message: '图纸名称不能为空', trigger: 'blur' }],
|
|
|
- source: [{ required: true, message: '图纸来源不能为空', trigger: 'blur' }]
|
|
|
+ async init (id, display) {
|
|
|
+ this.fileList = []
|
|
|
+ this.dataForm = {}
|
|
|
+ this.productDetails = []
|
|
|
+ this.materialList = []
|
|
|
+ this.optionsSource = []
|
|
|
+ this.optionsTech = []
|
|
|
+ this.optionsDraw = []
|
|
|
+ this.visible = true
|
|
|
+ this.id = id || 0
|
|
|
+ this.display = display
|
|
|
+ if (!id) return
|
|
|
+ await getDrawingDetail(this.id).then(({ data }) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.dataForm = data.data
|
|
|
+ // 图纸
|
|
|
+ if (data.data.attachList) {
|
|
|
+ data.data.attachList.forEach((item) => {
|
|
|
+ this.fileList.push({
|
|
|
+ name: item.fileName,
|
|
|
+ url: item.url,
|
|
|
+ id: item.url
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ validateField (type) {
|
|
|
+ this.$refs.dataForm.validateField(type)
|
|
|
+ },
|
|
|
+ uploadSuccess (fileList) {
|
|
|
+ this.fileList = fileList
|
|
|
},
|
|
|
- methods: {
|
|
|
- onChose () {
|
|
|
- this.$emit('onChose')
|
|
|
- },
|
|
|
- async init (id, display) {
|
|
|
- this.fileList = []
|
|
|
- this.dataForm = {}
|
|
|
- this.productDetails = []
|
|
|
- this.materialList = []
|
|
|
- this.optionsSource = []
|
|
|
- this.optionsTech = []
|
|
|
- this.optionsDraw = []
|
|
|
- this.visible = true
|
|
|
- this.id = id || 0
|
|
|
- this.display = display
|
|
|
- if (!id) return
|
|
|
- await getDrawingDetail(this.id).then(({data}) => {
|
|
|
- if (data && data.code === '200') {
|
|
|
- this.dataForm = data.data
|
|
|
- // 图纸
|
|
|
- if (data.data.attachList) {
|
|
|
- data.data.attachList.forEach((item) => {
|
|
|
- this.fileList.push({
|
|
|
- name: item.fileName,
|
|
|
- url: item.url,
|
|
|
- id: item.url
|
|
|
- })
|
|
|
+ // 表单提交
|
|
|
+ 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
|
|
|
}
|
|
|
- })
|
|
|
- },
|
|
|
- validateField (type) {
|
|
|
- this.$refs.dataForm.validateField(type)
|
|
|
- },
|
|
|
- uploadSuccess (fileList) {
|
|
|
- this.fileList = fileList
|
|
|
- },
|
|
|
- // 表单提交
|
|
|
- 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
|
|
|
- })
|
|
|
- }
|
|
|
+ this.$http({
|
|
|
+ url: !this.id
|
|
|
+ ? this.$http.adornUrl(`/biz-service/drawing/save`)
|
|
|
+ : this.$http.adornUrl(`/biz-service/drawing/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('请上传文件')
|
|
|
- return
|
|
|
+ this.$message.error(data.msg)
|
|
|
}
|
|
|
- this.$http({
|
|
|
- url: !this.id ? this.$http.adornUrl(`/biz-service/drawing/save`) : this.$http.adornUrl(`/biz-service/drawing/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)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-
|
|
|
+.tip {
|
|
|
+ color: gray;
|
|
|
+ padding-top: 20px;
|
|
|
+ display: inline-block;
|
|
|
+}
|
|
|
</style>
|