123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- // 合同模板-新增合同
- // 2019年6月20日 00:44:21 by jlx
- import {
- getTypeList
- } from '@/model/procurement/spare'
- import {
- createContract,
- updateContract,
- getContractDetail
- } from '@/model/procurement/basic'
- import Tinymce from '@/components/Tinymce'
- import MDinput from '@/components/MDinput'
- import Sticky from '@/components/Sticky' // 粘性header组件
- import { EventBus } from 'base-core-lib'
- export default {
- components: {
- Tinymce,
- MDinput,
- Sticky
- },
- data () {
- return {
- // 合同啊表单数据
- contractForm: {
- compId: sessionStorage.getItem('ws-pf_compId'),
- // 合同ID
- contractId: '',
- // 合同模板名称
- contractTitle: '',
- // 合同类型
- contractTypeId: '',
- // 合同内容
- contractContent: ''
- },
- // 合同模板类型数据
- contractList: [],
- // 表单验证
- rulesVendor: {
- contractTypeId: [{
- required: true
- }],
- contractTitle: [{
- required: true
- }]
- },
- }
- },
- created () {
- this.contractId = this.$route.query.contractId
- // 根据获取合同模板
- this.getSelectContract()
- if (this.contractId.length > 0) {
- this.getContractByContractId()
- }
- },
- computed: {
- getLanguage () {
- return this.$store.getters.language
- }
- },
- methods: {
- // 根据获取合同模板
- getSelectContract () {
- // 获取数据
- getTypeList({
- compId: sessionStorage.getItem('ws-pf_compId'),
- constCode: 'CONTRACT_INQUIRY'
- }).toPromise().then(response => {
- this.contractList = response
- })
- },
- // 根据合同ID获取合同明细信息
- getContractByContractId () {
- getContractDetail({
- contractId: this.contractId
- }).toPromise().then(response => {
- this.contractForm = response
- })
- },
- // 保存
- save () {
- // 新增
- this.$refs['dataForm'].validate(valid => {
- if (valid) {
- if (this.contractForm.contractContent.length == 0) {
- EventBus.$emit('error', this.$t('message.message3'))
- return
- }
- // ([\u4e00-\u9fa50-9 -~A-Za-z]+)<\/span>
- this.contractForm.contractContent = this.contractForm.contractContent.replace(/<span style="color: #ff0000;">([\u4e00-\u9fa50-9 A-Za-z]+)</g, `<input type="text" placeholder="请输入" onblur="this.setAttribute('value', this.value)" /><`)
- if (this.contractForm.contractId.length == 0) {
- createContract(this.contractForm).toPromise().then(response => {
- EventBus.$emit('success', this.$t('message.message1'))
- this.back()
- })
- } else {
- updateContract(this.contractForm).toPromise().then(response => {
- EventBus.$emit('success', this.$t('message.message1'))
- this.back()
- })
- }
- } else {
- EventBus.$emit('error', this.$t('showMessage.asterisksArereQuired'))
- }
- })
- },
- // 返回列表页面
- back () {
- this.$router.go(-1) // 返回上一层
- }
- }
- }
|