detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-detail-page-layout @save="handleCreate" :edit-status="true" v-loading="vLoading" element-loading-text="处理中。。。" :list-query="listQuery">
  7. <div style="padding-top: 30px;">
  8. <el-tabs v-model="activeName">
  9. <el-tab-pane label="项目信息" name="first">
  10. <el-form ref="postForm" :model="postForm" class="form-container">
  11. <div class="createPost-main-container">
  12. <div class="postInfo-container">
  13. <div style="margin-bottom: 30px">
  14. <h3 class="title">
  15. <div class="avatar-wrapper icon-title">基</div>
  16. <div class="icon-info">基本信息</div>
  17. </h3>
  18. </div>
  19. <el-row>
  20. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  21. <el-form-item
  22. label="项目名称:"
  23. prop="name"
  24. :rules="{required: true, message: '请输入项目名称', trigger: 'blur'}"
  25. label-width="120px"
  26. class="postInfo-container-item"
  27. >
  28. <el-input v-model="postForm.name" class="filter-item"/>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  32. <el-form-item
  33. label="归属单位:"
  34. prop="belongTo"
  35. :rules="{required: true, message: '归属单位', trigger: 'blur'}"
  36. label-width="120px"
  37. class="postInfo-container-item"
  38. >
  39. <el-select
  40. v-model="postForm.belongTo"
  41. placeholder="请选择"
  42. clearable
  43. filterable
  44. class="filter-item"
  45. style=" width: 100%"
  46. @change="changePrefix"
  47. >
  48. <el-option key="1" label="大友" value="DY"/>
  49. <el-option key="2" label="泰济诚" value="TJC"/>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  54. <el-form-item
  55. label="项目编号:"
  56. prop="oaNo"
  57. label-width="120px"
  58. class="postInfo-container-item"
  59. >
  60. <el-input v-model="postForm.oaNo" class="filter-item" :placeholder="tip" :disabled="oaNoDisable" :readonly="oaNoReadonly">
  61. <template slot="prepend">{{postForm.belongTo}}</template>
  62. </el-input>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  66. <el-form-item
  67. label="事业部流水号:"
  68. prop="businessNo"
  69. label-width="150px"
  70. class="postInfo-container-item"
  71. >
  72. <el-input :value="postForm.businessNo" class="filter-item" placeholder="系统自动生成" :disabled="true" readonly/>
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. <el-row>
  77. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  78. <el-form-item
  79. label="项目类型:"
  80. prop="cate"
  81. :rules="{required: true, message: '项目类型', trigger: 'blur'}"
  82. label-width="120px"
  83. class="postInfo-container-item"
  84. >
  85. <el-select
  86. v-model="postForm.cate"
  87. placeholder="请选择"
  88. clearable
  89. filterable
  90. class="filter-item"
  91. style=" width: 100%"
  92. >
  93. <el-option v-for="item in cateList" :key="item.id" :label="item.name" :value="item.id"/>
  94. </el-select>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  98. <el-form-item
  99. label="客户名字:"
  100. prop="customerId"
  101. label-width="120px"
  102. class="postInfo-container-item"
  103. >
  104. <el-select v-model="customerInfo" filterable class="filter-item" style="float: left;width: 100%;" placeholder="请选择" @change="getCustomerDetail">
  105. <el-option
  106. v-for="item in customerOptions"
  107. :key="item.id"
  108. :label="item.name"
  109. :value="[item.id,item.name]"
  110. />
  111. </el-select>
  112. <el-select v-show="false" v-model="postForm.clientName" />
  113. </el-form-item>
  114. </el-col>
  115. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  116. <el-form-item
  117. label="委托单位:"
  118. prop="clientUnit"
  119. label-width="120px"
  120. class="postInfo-container-item"
  121. >
  122. <el-input :value="postForm.clientUnit" class="filter-item" readonly disabled/>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  126. <el-form-item
  127. label="联系方式:"
  128. prop="mobile"
  129. label-width="120px"
  130. class="postInfo-container-item"
  131. >
  132. <el-input :value="postForm.mobile" class="filter-item" readonly disabled />
  133. </el-form-item>
  134. </el-col>
  135. </el-row>
  136. <el-row>
  137. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  138. <el-form-item
  139. label="客户经理:"
  140. prop="clientManager"
  141. label-width="120px"
  142. class="postInfo-container-item"
  143. >
  144. <el-input :value="postForm.clientManager" class="filter-item" readonly disabled/>
  145. </el-form-item>
  146. </el-col>
  147. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  148. <el-form-item
  149. label="业务来源:"
  150. prop="businessSource"
  151. :rules="{required: true, message: '请输入业务来源', trigger: 'blur'}"
  152. label-width="120px"
  153. class="postInfo-container-item"
  154. >
  155. <el-select
  156. v-model="postForm.businessSource"
  157. placeholder="请选择"
  158. clearable
  159. filterable
  160. class="filter-item"
  161. style=" width: 100%"
  162. >
  163. <el-option v-for="item in businessSourceList" :key="item.id" :label="item.name" :value="item.id"/>
  164. </el-select>
  165. </el-form-item>
  166. </el-col>
  167. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  168. <el-form-item
  169. label="项目负责人:"
  170. prop="skiller"
  171. :rules="{required: true, message: '请输入项目负责人', trigger: 'blur'}"
  172. label-width="120px"
  173. class="postInfo-container-item"
  174. >
  175. <el-input v-model="postForm.skiller" class="filter-item"/>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  179. <el-form-item
  180. label="签订日期:"
  181. prop="signDate"
  182. label-width="120px"
  183. class="postInfo-container-item"
  184. >
  185. <el-date-picker
  186. v-model="postForm.signDate"
  187. type="date"
  188. value-format="yyyy-MM-dd"
  189. style="width: 100%"
  190. placeholder="选择日期"
  191. />
  192. </el-form-item>
  193. </el-col>
  194. </el-row>
  195. <el-row>
  196. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  197. <el-form-item
  198. label="付款类型:"
  199. prop="paymentMethod"
  200. :rules="{required: true, message: '请输入付款方式', trigger: 'blur'}"
  201. label-width="120px"
  202. class="postInfo-container-item"
  203. >
  204. <el-select
  205. v-model="postForm.paymentMethod"
  206. placeholder="请选择"
  207. clearable
  208. filterable
  209. class="filter-item"
  210. style=" width: 100%"
  211. >
  212. <el-option key="1" label="一次性付款" value="一次性付款"/>
  213. <el-option key="2" label="分期付款" value="分期付款"/>
  214. </el-select>
  215. </el-form-item>
  216. </el-col>
  217. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  218. <el-form-item
  219. label="合同金额:"
  220. prop="amount"
  221. label-width="120px"
  222. class="postInfo-container-item"
  223. >
  224. <el-input v-model.number="postForm.amount" class="filter-item" type="number">
  225. <i slot="suffix" style="font-size:normal;margin-right: 10px;line-height: 30px">元</i>
  226. </el-input>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  230. <el-form-item
  231. label="所属部门:"
  232. prop="departmentId"
  233. :rules="{required: true, message: '请选择所属部门', trigger: 'blur'}"
  234. label-width="120px"
  235. class="postInfo-container-item"
  236. >
  237. <el-select
  238. v-model="postForm.departmentId"
  239. placeholder="请选择"
  240. clearable
  241. filterable
  242. class="filter-item"
  243. style=" width: 100%"
  244. >
  245. <el-option
  246. v-for="item in departmentsOptions"
  247. :key="item.id"
  248. :label="item.name"
  249. :value="item.id"
  250. />
  251. </el-select>
  252. </el-form-item>
  253. </el-col>
  254. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  255. <el-form-item label-width="120px" v-model="postForm.contractUrl" style=" width: 100%">
  256. <el-upload
  257. action="/api/upload"
  258. :limit="1" :on-success="changeres" :on-exceed="handleExceed" :on-preview="handleAttachmentPreview"
  259. :file-list="fileList" :before-remove="beforeRemove">
  260. <el-button type="primary">上传电子合同<i class="el-icon-upload el-icon--right"></i></el-button>
  261. </el-upload>
  262. </el-form-item>
  263. </el-col>
  264. </el-row>
  265. <div style="margin-top:20px;width:100%;height:1px;background:rgba(242,242,242,1);"/>
  266. <div style="margin-bottom: 30px">
  267. <h3 class="title">
  268. <div class="avatar-wrapper icon-title" style="background:rgba(255,175,41,1)">人</div>
  269. <div class="icon-info">
  270. 人员配置
  271. <span style="color: orangered">*</span>
  272. </div>
  273. </h3>
  274. </div>
  275. </div>
  276. <el-transfer
  277. filterable
  278. :filter-method="filterMethod"
  279. filter-placeholder="请输入姓名"
  280. v-model="userIds"
  281. :titles="['所有员工', '所选员工']"
  282. :data="users"
  283. >
  284. </el-transfer>
  285. </div>
  286. </el-form>
  287. </el-tab-pane>
  288. </el-tabs>
  289. </div>
  290. </y-detail-page-layout>
  291. </div>
  292. </template>
  293. <script>
  294. import Breadcrumb from '@/components/Breadcrumb'
  295. import YDetailPageLayout from '@/components/YDetailPageLayout'
  296. export default {
  297. name: 'itemDetail',
  298. components: {
  299. Breadcrumb,
  300. YDetailPageLayout,
  301. },
  302. data() {
  303. return {
  304. type: 'detail',
  305. postForm: {
  306. departmentId:'',
  307. clientUnit:'',
  308. mobile:'',
  309. userId: this.$store.getters.userInfo.id,
  310. clientManager:this.$store.getters.userInfo.name,
  311. oaNo:''
  312. },
  313. dataId: this.$route.query.id,
  314. activeName: 'first',
  315. vLoading: false,
  316. users:[],
  317. listQuery:null,
  318. userIds: [],
  319. filterMethod(query, item) {
  320. return item.label.indexOf(query) > -1;
  321. },
  322. departmentsOptions:[],
  323. contractName:'',
  324. fileList:[],
  325. customerOptions:[],
  326. customerInfo:[],
  327. tip:null,
  328. oaNoDisable:false,
  329. oaNoReadonly:false,
  330. cateList:[],
  331. businessSourceList:[]
  332. }
  333. },
  334. created() {
  335. this.listQuery = this.$route.query.listQuery;
  336. this.getAllUser();
  337. this.getDepartment();
  338. this.getDetail();
  339. this.getCustomerSelect();
  340. this.getCateList();
  341. this.getBusinessSourceList();
  342. },
  343. methods: {
  344. getCateList(){
  345. this.$api.dictData.simpleType("项目类型").then(res => {
  346. this.cateList = res.data
  347. })
  348. },
  349. getBusinessSourceList(){
  350. this.$api.dictData.simpleType("业务来源").then(res => {
  351. this.businessSourceList = res.data
  352. })
  353. },
  354. getCustomerDetail(){
  355. this.postForm.clientName = this.customerInfo[1];
  356. this.postForm.customerId = this.customerInfo[0];
  357. this.$api.customer.detail(this.postForm.customerId).then(res =>{
  358. this.postForm.clientUnit = res.data.department;
  359. this.postForm.mobile = res.data.mobile;
  360. })
  361. },
  362. getCustomerSelect() {
  363. this.$api.customer.simpleAll().then(res => {
  364. this.customerOptions = res.data
  365. })
  366. }, handleAttachmentPreview(file){
  367. window.open(file.url)
  368. },
  369. handleExceed(files, fileList) {
  370. this.$message.warning(`当前限制选择 1个文件,本次选择了 ${files.length} 个文件`);
  371. },
  372. // 上传
  373. changeres(res, file) {
  374. if (res.code === 200){
  375. this.postForm.contractUrl = res.data.url;
  376. const arr = res.data.url.split("-");
  377. this.contractName = arr[1];
  378. }else {
  379. this.$notify({
  380. title: '错误',
  381. message: '合同上传失败',
  382. type: 'error',
  383. duration: 2000
  384. });
  385. return;
  386. }
  387. },
  388. changePrefix(e){
  389. this.postForm.belongTo = e;
  390. this.postForm.oaNo = '';
  391. if (e === 'TJC'){
  392. this.tip = '事业部流水号';
  393. this.oaNoDisable = true;
  394. this.oaNoReadonly = true;
  395. }
  396. if (e === 'DY'){
  397. this.tip = null;
  398. this.oaNoDisable = false;
  399. this.oaNoReadonly = false;
  400. }
  401. this.postForm.oaNo = null;
  402. },
  403. getZero(num) {
  404. // 单数前面加0
  405. if (parseInt(num) < 10) {
  406. num = '0' + num;
  407. }
  408. return num;
  409. },
  410. getAllUser() {
  411. const that = this;
  412. that.$api.user.simpleAll().then(data => {
  413. if (data.code === 200) {
  414. this.users = data.data.map((item) => {
  415. return {
  416. key: item.id,
  417. label: item.name,
  418. };
  419. });
  420. } else {
  421. this.$message({
  422. type: 'error',
  423. message: data.msg
  424. })
  425. }
  426. })
  427. },
  428. getDepartment(){
  429. this.$api.department.simpleAll().then(res => {
  430. this.departmentsOptions = res.data
  431. })
  432. },
  433. getDetail() {
  434. if (this.dataId) {
  435. this.$api.item.detail(this.dataId).then(res => {
  436. this.postForm = res.data;
  437. this.customerInfo = res.data.clientName;
  438. if (res.data.contractUrl){
  439. const arr = res.data.contractUrl.split("-");
  440. this.contractName = arr[1];
  441. this.fileList.push({name: this.contractName, url:this.postForm.contractUrl});
  442. }
  443. this.userIds = res.data.userIds.map(item => {
  444. return item
  445. })
  446. });
  447. }
  448. },
  449. handleCreate() {
  450. if (this.userIds.length==0){
  451. this.$notify({
  452. title: '错误',
  453. message: '人员配置不能为空',
  454. type: 'error',
  455. duration: 2000
  456. });
  457. return;
  458. }
  459. if (this.postForm.contractUrl){
  460. const date = new Date();
  461. this.postForm.uploadDate = date.getFullYear() + "-" + (this.getZero(date.getMonth() + 1)) + "-" + this.getZero((date.getDate()));
  462. }else {
  463. this.postForm.uploadDate = null;
  464. }
  465. this.$refs.postForm.validate(valid => {
  466. if (valid) {
  467. if (this.dataId) {
  468. this.$api.item.edit(Object.assign({}, this.postForm, {
  469. userIds: this.userIds.map(item => { return item }),
  470. })).then(res => {
  471. if (res.code === 200) {
  472. this.$notify({
  473. title: '成功',
  474. message: '保存成功',
  475. type: 'success',
  476. duration: 2000
  477. });
  478. const back = this.$route.query.back;
  479. if (back) {
  480. this.$router.push(back)
  481. }
  482. this.initData();
  483. this.vLoading = false
  484. }
  485. }).catch(() => {
  486. this.vLoading = false
  487. })
  488. } else {
  489. this.$api.item.add(Object.assign({}, this.postForm, {
  490. userIds: this.userIds.map(item => { return item }),
  491. })).then(res => {
  492. if (res.code === 200) {
  493. this.$notify({
  494. title: '成功',
  495. message: '新增成功',
  496. type: 'success',
  497. duration: 2000
  498. });
  499. const back = this.$route.query.back;
  500. if (back) {
  501. this.$router.push(back)
  502. }
  503. this.initData();
  504. this.vLoading = false
  505. }
  506. }).catch(() => {
  507. this.vLoading = false
  508. })
  509. }
  510. }
  511. })
  512. },
  513. beforeRemove(file, fileList) {
  514. this.$confirm(`确定移除 ${ file.name }?`, '警告', {
  515. confirmButtonText: '确认',
  516. cancelButtonText: '取消',
  517. type: 'warning',
  518. })
  519. .then(async () => {
  520. this.postForm.contractUrl = '';
  521. })
  522. }
  523. }
  524. }
  525. </script>
  526. <style lang="scss" scoped>
  527. </style>