123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <template>
- <div>
- <el-dialog
- :title="display ? '工艺详情' : '新建工艺'"
- width="70%"
- :close-on-click-modal="false"
- :visible.sync="visible"
- >
- <el-form
- :model="dataForm"
- :rules="dataRule"
- ref="dataForm"
- label-width="auto"
- >
- <el-row class="my-row">
- <el-col :span="8">
- <el-form-item label="工艺名称" prop="techName">
- <el-input
- v-model="dataForm.techName"
- :disabled="display"
- placeholder="工艺名称"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="工艺版本" prop="techVersion">
- <el-input
- v-model="dataForm.techVersion"
- :disabled="display"
- placeholder="工艺版本"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="产品" prop="productId">
- <el-select
- v-model="dataForm.productId"
- :disabled="display"
- remote
- placeholder="请选择"
- >
- <el-option
- v-for="item in optionLevel"
- :key="item.productId"
- :label="item.productName"
- :value="item.productId"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="备注说明">
- <el-input
- v-model="dataForm.notes"
- :disabled="display"
- placeholder="备注说明"
- ></el-input>
- </el-form-item>
- <el-form-item label="" label-width="0px">
- <upload-component
- :display="display"
- :title="'附件'"
- :accept="'*'"
- :file-obj-list="fileList"
- @uploadSuccess="uploadSuccess"
- />
- </el-form-item>
- <el-form-item label="工艺步骤" prop="nodeList"> </el-form-item>
- <el-row
- class="my-row"
- style="height: 350px; background-color: #efefef;"
- >
- <work-flow
- ref="workFlow"
- :nodeData="workFlowData"
- @saveWorkFlow="saveWorkFlow"
- ></work-flow>
- </el-row>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="visible = false">取消</el-button>
- <el-button v-if="!display" type="primary" @click="dataFormSubmit()"
- >确定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getInfo, getProduct, getWorkType } from '@/api/crafts'
- import UploadComponent from '../common/upload-component'
- import WorkFlow from '@/components/work-flow/home'
- // import data from "@/components/work-flow/config/data.json";
- export default {
- name: 'add-or-update',
- components: { UploadComponent, WorkFlow },
- computed: {
- orgId: {
- get () {
- return this.$store.state.user.orgId
- }
- }
- },
- data () {
- return {
- workTypeOptions: [],
- datas: {},
- visible: false,
- display: false,
- fileList: [],
- dataList: [],
- id: 0,
- dataForm: {
- techName: '',
- techVersion: '',
- productId: '',
- notes: ''
- },
- previewPath: '',
- previewName: '',
- previewVisible: false,
- optionsProducts: [],
- optionLevel: [],
- workFlowData: {
- nodeList: [],
- lineList: []
- }, // 流程图数据
- dataRule: {
- techName: [
- { required: true, message: '工艺名称不能为空', trigger: 'blur' }
- ],
- techVersion: [
- { required: true, message: '工艺版本不能为空', trigger: 'blur' }
- ],
- productId: [
- { required: true, message: '产品不能为空', trigger: 'change' }
- ]
- },
- dataRule1: {
- name: [
- { required: true, message: '节点名称不能为空', trigger: 'blur' }
- ],
- type: [
- { required: true, message: '节点类型不能为空', trigger: 'change' }
- ],
- workTypeId: [
- { required: true, message: '工种不能为空', trigger: 'change' }
- ]
- }
- }
- },
- created () {
- this.initNode()
- },
- mounted () {
- this.initNode()
- },
- methods: {
- initNode () {
- // this.workFlowData = data;
- },
- resetWorkFlow () {
- this.workFlowData = {
- nodeList: [],
- lineList: []
- }
- },
- async init (id, display) {
- this.dataForm = {
- techName: '',
- techVersion: '',
- productId: '',
- notes: ''
- }
- this.visible = true
- this.display = display
- await getProduct({ current: 1, size: 20000 }).then(({ data }) => {
- if (data && data.code === '200') {
- this.optionLevel = data.data.records
- }
- })
- if (!id) return
- await getInfo(id).then(async ({ data }) => {
- if (data && data.code === '200') {
- this.dataForm = data.data
- }
- })
- },
- getWorkType () {
- getWorkType().then(({ data }) => {
- if (data && data.code === '200') {
- this.workTypeOptions = data.data
- }
- })
- },
- handleRemove (file, fileList) {
- this.fileList = fileList
- },
- handleChange (file, fileList) {
- this.fileList = fileList
- },
- handleExceed (files, fileList) {
- this.$message.warning(
- `当前限制选择 5 个文件,本次选择了 ${
- files.length
- } 个文件,共选择了 ${files.length + fileList.length} 个文件`
- )
- },
- validateField (type) {
- this.$refs.dataForm.validateField(type)
- },
- // 表单提交
- dataFormSubmit () {
- if (!this.workFlowData) {
- this.$message.error('请先完成流程图!')
- return
- }
- 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.$http.adornUrl(`/biz-service/technology/submit`),
- method: 'post',
- data: this.$http.adornData({
- ...this.dataForm,
- ...this.workFlowData
- })
- }).then(({ data }) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.resetWorkFlow()
- this.$emit('refreshDataList')
- this.visible = false
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }
- })
- },
- uploadSuccess (fileList) {
- this.fileList = fileList
- },
- // 保存流程图
- saveWorkFlow (workFlowData) {
- this.workFlowData = workFlowData
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .super-flow__node {
- .flow-node {
- > header {
- font-size: 14px;
- height: 32px;
- line-height: 32px;
- padding: 0 12px;
- color: #ffffff;
- }
- > section {
- text-align: center;
- line-height: 20px;
- overflow: hidden;
- padding: 6px 12px;
- word-break: break-all;
- }
- &.flow-node-start {
- > header {
- background-color: #55abfc;
- }
- }
- &.flow-node-condition {
- > header {
- background-color: #bc1d16;
- }
- }
- &.flow-node-approval {
- > header {
- background-color: rgba(188, 181, 58, 0.76);
- }
- }
- &.flow-node-cc {
- > header {
- background-color: #30b95c;
- }
- }
- &.flow-node-end {
- > header {
- height: 50px;
- line-height: 50px;
- background-color: rgb(0, 0, 0);
- }
- }
- }
- }
- </style>
|