123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- <template>
- <div class="app-container">
- <div class="title-container">
- <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
- </div>
- <y-detail-page-layout @save="handleCreate" :edit-status="true" v-loading="vLoading" element-loading-text="处理中。。。" :list-query="listQuery">
- <div style="padding-top: 30px;">
- <el-tabs v-model="activeName">
- <el-tab-pane label="项目信息" name="first">
- <el-form ref="postForm" :model="postForm" class="form-container">
- <div class="createPost-main-container">
- <div class="postInfo-container">
- <div style="margin-bottom: 30px">
- <h3 class="title">
- <div class="avatar-wrapper icon-title">基</div>
- <div class="icon-info">基本信息</div>
- </h3>
- </div>
- <el-row>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="项目名称:"
- prop="name"
- :rules="{required: true, message: '请输入项目名称', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input v-model="postForm.name" class="filter-item"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="归属单位:"
- prop="belongTo"
- :rules="{required: true, message: '归属单位', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-select
- v-model="postForm.belongTo"
- placeholder="请选择"
- clearable
- filterable
- class="filter-item"
- style=" width: 100%"
- @change="changePrefix"
- >
- <el-option key="1" label="大友" value="DY"/>
- <el-option key="2" label="泰济诚" value="TJC"/>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="项目编号:"
- prop="oaNo"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input v-model="postForm.oaNo" class="filter-item" :placeholder="tip" :disabled="oaNoDisable" :readonly="oaNoReadonly">
- <template slot="prepend">{{postForm.belongTo}}</template>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="事业部流水号:"
- prop="businessNo"
- label-width="150px"
- class="postInfo-container-item"
- >
- <el-input :value="postForm.businessNo" class="filter-item" placeholder="系统自动生成" :disabled="true" readonly/>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="项目类型:"
- prop="cate"
- :rules="{required: true, message: '项目类型', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-select
- v-model="postForm.cate"
- placeholder="请选择"
- clearable
- filterable
- class="filter-item"
- style=" width: 100%"
- >
- <el-option v-for="item in cateList" :key="item.id" :label="item.name" :value="item.id"/>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="客户名字:"
- prop="customerId"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-select v-model="customerInfo" filterable class="filter-item" style="float: left;width: 100%;" placeholder="请选择" @change="getCustomerDetail">
- <el-option
- v-for="item in customerOptions"
- :key="item.id"
- :label="item.name"
- :value="[item.id,item.name]"
- />
- </el-select>
- <el-select v-show="false" v-model="postForm.clientName" />
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="委托单位:"
- prop="clientUnit"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input :value="postForm.clientUnit" class="filter-item" readonly disabled/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="联系方式:"
- prop="mobile"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input :value="postForm.mobile" class="filter-item" readonly disabled />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="客户经理:"
- prop="clientManager"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input :value="postForm.clientManager" class="filter-item" readonly disabled/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="业务来源:"
- prop="businessSource"
- :rules="{required: true, message: '请输入业务来源', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-select
- v-model="postForm.businessSource"
- placeholder="请选择"
- clearable
- filterable
- class="filter-item"
- style=" width: 100%"
- >
- <el-option v-for="item in businessSourceList" :key="item.id" :label="item.name" :value="item.id"/>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="项目负责人:"
- prop="skiller"
- :rules="{required: true, message: '请输入项目负责人', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input v-model="postForm.skiller" class="filter-item"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="签订日期:"
- prop="signDate"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-date-picker
- v-model="postForm.signDate"
- type="date"
- value-format="yyyy-MM-dd"
- style="width: 100%"
- placeholder="选择日期"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="付款类型:"
- prop="paymentMethod"
- :rules="{required: true, message: '请输入付款方式', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-select
- v-model="postForm.paymentMethod"
- placeholder="请选择"
- clearable
- filterable
- class="filter-item"
- style=" width: 100%"
- >
- <el-option key="1" label="一次性付款" value="一次性付款"/>
- <el-option key="2" label="分期付款" value="分期付款"/>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="合同金额:"
- prop="amount"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-input v-model.number="postForm.amount" class="filter-item" type="number">
- <i slot="suffix" style="font-size:normal;margin-right: 10px;line-height: 30px">元</i>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item
- label="所属部门:"
- prop="departmentId"
- :rules="{required: true, message: '请选择所属部门', trigger: 'blur'}"
- label-width="120px"
- class="postInfo-container-item"
- >
- <el-select
- v-model="postForm.departmentId"
- placeholder="请选择"
- clearable
- filterable
- class="filter-item"
- style=" width: 100%"
- >
- <el-option
- v-for="item in departmentsOptions"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" :span="6">
- <el-form-item label-width="120px" v-model="postForm.contractUrl" style=" width: 100%">
- <el-upload
- action="/api/upload"
- :limit="1" :on-success="changeres" :on-exceed="handleExceed" :on-preview="handleAttachmentPreview"
- :file-list="fileList" :before-remove="beforeRemove">
- <el-button type="primary">上传电子合同<i class="el-icon-upload el-icon--right"></i></el-button>
- </el-upload>
- </el-form-item>
- </el-col>
- </el-row>
- <div style="margin-top:20px;width:100%;height:1px;background:rgba(242,242,242,1);"/>
- <div style="margin-bottom: 30px">
- <h3 class="title">
- <div class="avatar-wrapper icon-title" style="background:rgba(255,175,41,1)">人</div>
- <div class="icon-info">
- 人员配置
- <span style="color: orangered">*</span>
- </div>
- </h3>
- </div>
- </div>
- <el-transfer
- filterable
- :filter-method="filterMethod"
- filter-placeholder="请输入姓名"
- v-model="userIds"
- :titles="['所有员工', '所选员工']"
- :data="users"
- >
- </el-transfer>
- </div>
- </el-form>
- </el-tab-pane>
- </el-tabs>
- </div>
- </y-detail-page-layout>
- </div>
- </template>
- <script>
- import Breadcrumb from '@/components/Breadcrumb'
- import YDetailPageLayout from '@/components/YDetailPageLayout'
- export default {
- name: 'itemDetail',
- components: {
- Breadcrumb,
- YDetailPageLayout,
- },
- data() {
- return {
- type: 'detail',
- postForm: {
- departmentId:'',
- clientUnit:'',
- mobile:'',
- userId: this.$store.getters.userInfo.id,
- clientManager:this.$store.getters.userInfo.name,
- oaNo:''
- },
- dataId: this.$route.query.id,
- activeName: 'first',
- vLoading: false,
- users:[],
- listQuery:null,
- userIds: [],
- filterMethod(query, item) {
- return item.label.indexOf(query) > -1;
- },
- departmentsOptions:[],
- contractName:'',
- fileList:[],
- customerOptions:[],
- customerInfo:[],
- tip:null,
- oaNoDisable:false,
- oaNoReadonly:false,
- cateList:[],
- businessSourceList:[]
- }
- },
- created() {
- this.listQuery = this.$route.query.listQuery;
- this.getAllUser();
- this.getDepartment();
- this.getDetail();
- this.getCustomerSelect();
- this.getCateList();
- this.getBusinessSourceList();
- },
- methods: {
- getCateList(){
- this.$api.dictData.simpleType("项目类型").then(res => {
- this.cateList = res.data
- })
- },
- getBusinessSourceList(){
- this.$api.dictData.simpleType("业务来源").then(res => {
- this.businessSourceList = res.data
- })
- },
- getCustomerDetail(){
- this.postForm.clientName = this.customerInfo[1];
- this.postForm.customerId = this.customerInfo[0];
- this.$api.customer.detail(this.postForm.customerId).then(res =>{
- this.postForm.clientUnit = res.data.department;
- this.postForm.mobile = res.data.mobile;
- })
- },
- getCustomerSelect() {
- this.$api.customer.simpleAll().then(res => {
- this.customerOptions = res.data
- })
- }, handleAttachmentPreview(file){
- window.open(file.url)
- },
- handleExceed(files, fileList) {
- this.$message.warning(`当前限制选择 1个文件,本次选择了 ${files.length} 个文件`);
- },
- // 上传
- changeres(res, file) {
- if (res.code === 200){
- this.postForm.contractUrl = res.data.url;
- const arr = res.data.url.split("-");
- this.contractName = arr[1];
- }else {
- this.$notify({
- title: '错误',
- message: '合同上传失败',
- type: 'error',
- duration: 2000
- });
- return;
- }
- },
- changePrefix(e){
- this.postForm.belongTo = e;
- this.postForm.oaNo = '';
- if (e === 'TJC'){
- this.tip = '事业部流水号';
- this.oaNoDisable = true;
- this.oaNoReadonly = true;
- }
- if (e === 'DY'){
- this.tip = null;
- this.oaNoDisable = false;
- this.oaNoReadonly = false;
- }
- this.postForm.oaNo = null;
- },
- getZero(num) {
- // 单数前面加0
- if (parseInt(num) < 10) {
- num = '0' + num;
- }
- return num;
- },
- getAllUser() {
- const that = this;
- that.$api.user.simpleAll().then(data => {
- if (data.code === 200) {
- this.users = data.data.map((item) => {
- return {
- key: item.id,
- label: item.name,
- };
- });
- } else {
- this.$message({
- type: 'error',
- message: data.msg
- })
- }
- })
- },
- getDepartment(){
- this.$api.department.simpleAll().then(res => {
- this.departmentsOptions = res.data
- })
- },
- getDetail() {
- if (this.dataId) {
- this.$api.item.detail(this.dataId).then(res => {
- this.postForm = res.data;
- this.customerInfo = res.data.clientName;
- if (res.data.contractUrl){
- const arr = res.data.contractUrl.split("-");
- this.contractName = arr[1];
- this.fileList.push({name: this.contractName, url:this.postForm.contractUrl});
- }
- this.userIds = res.data.userIds.map(item => {
- return item
- })
- });
- }
- },
- handleCreate() {
- if (this.userIds.length==0){
- this.$notify({
- title: '错误',
- message: '人员配置不能为空',
- type: 'error',
- duration: 2000
- });
- return;
- }
- if (this.postForm.contractUrl){
- const date = new Date();
- this.postForm.uploadDate = date.getFullYear() + "-" + (this.getZero(date.getMonth() + 1)) + "-" + this.getZero((date.getDate()));
- }else {
- this.postForm.uploadDate = null;
- }
- this.$refs.postForm.validate(valid => {
- if (valid) {
- if (this.dataId) {
- this.$api.item.edit(Object.assign({}, this.postForm, {
- userIds: this.userIds.map(item => { return item }),
- })).then(res => {
- if (res.code === 200) {
- this.$notify({
- title: '成功',
- message: '保存成功',
- type: 'success',
- duration: 2000
- });
- const back = this.$route.query.back;
- if (back) {
- this.$router.push(back)
- }
- this.initData();
- this.vLoading = false
- }
- }).catch(() => {
- this.vLoading = false
- })
- } else {
- this.$api.item.add(Object.assign({}, this.postForm, {
- userIds: this.userIds.map(item => { return item }),
- })).then(res => {
- if (res.code === 200) {
- this.$notify({
- title: '成功',
- message: '新增成功',
- type: 'success',
- duration: 2000
- });
- const back = this.$route.query.back;
- if (back) {
- this.$router.push(back)
- }
- this.initData();
- this.vLoading = false
- }
- }).catch(() => {
- this.vLoading = false
- })
- }
- }
- })
- },
- beforeRemove(file, fileList) {
- this.$confirm(`确定移除 ${ file.name }?`, '警告', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(async () => {
- this.postForm.contractUrl = '';
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|