editContract.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :inline="true"
  5. ref="form"
  6. :model="form"
  7. :rules="rules"
  8. label-width="auto"
  9. style="margin-top: 20px"
  10. >
  11. <el-divider content-position="left">基本信息</el-divider>
  12. <!-- <el-form-item label="融资产品编号" prop="zfpNumber">
  13. <el-input v-model="form.zfpNumber" placeholder="请输入融资产品编号" />
  14. </el-form-item> -->
  15. <el-row>
  16. <el-col :span="8">
  17. <el-form-item
  18. label="合同模板名称:"
  19. prop="zfcName"
  20. >
  21. <el-input
  22. v-model="form.zfcName"
  23. placeholder="请输入合同模板名称"
  24. maxlength="20"
  25. /> </el-form-item
  26. ></el-col>
  27. <el-col :span="8"
  28. ><el-form-item
  29. label="合同类型:"
  30. prop="zfcType"
  31. >
  32. <el-select
  33. v-model="form.zfcType"
  34. placeholder="请选择合同类型"
  35. clearable
  36. size="small"
  37. >
  38. <el-option
  39. v-for="dict in typeOptions"
  40. :key="dict.dictValue"
  41. :label="dict.dictLabel"
  42. :value="dict.dictValue"
  43. />
  44. </el-select> </el-form-item
  45. ></el-col>
  46. <el-col :span="8">
  47. <el-form-item
  48. label="资金方:"
  49. prop="zfcManagementId"
  50. >
  51. <el-select
  52. style="width: 95%"
  53. v-model="form.zfcManagementId"
  54. filterable
  55. placeholder="请选择资金方"
  56. clearable
  57. size="small"
  58. >
  59. <el-option
  60. v-for="(item, index) in companyList"
  61. :key="index"
  62. :label="item.scyName"
  63. :value="item.scyId"
  64. />
  65. </el-select> </el-form-item
  66. ></el-col>
  67. </el-row>
  68. <el-row>
  69. <el-form-item style="margin-left: 100px" >
  70. <el-table ref="tableContract" :data="nodeList" @selection-change="handleSelectionChange" style="width: 500px" >
  71. <el-table-column
  72. type="selection"
  73. width="50"
  74. align="center"/>
  75. <el-table-column label="签署节点" align="center" prop="zfcNode" :show-overflow-tooltip="true" >
  76. </el-table-column>
  77. <el-table-column label="盖章关键字" align="center" prop="zfcSignKeyword" :show-overflow-tooltip="true">
  78. <template slot-scope="scope">
  79. <el-input
  80. v-model="scope.row.zfcSignKeyword"
  81. size="small"
  82. maxlength="200"
  83. ></el-input>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. </el-form-item
  88. >
  89. <!-- <el-col :span="8">
  90. <el-form-item
  91. label="签署主体:"
  92. prop="zfcSubject"
  93. >
  94. <el-select
  95. v-model="form.zfcSubject"
  96. placeholder="请选择签署主体"
  97. clearable
  98. size="small"
  99. >
  100. <el-option
  101. v-for="dict in subjectOptions"
  102. :key="dict.dictValue"
  103. :label="dict.dictLabel"
  104. :value="dict.dictValue"
  105. />
  106. </el-select> </el-form-item
  107. ></el-col>
  108. <el-col :span="8">
  109. <el-form-item
  110. label="签署节点:"
  111. prop="zfcNode"
  112. >
  113. <el-select
  114. v-model="form.zfcNode"
  115. placeholder="请选择签署节点"
  116. clearable
  117. size="small"
  118. >
  119. <el-option
  120. v-for="dict in nodeOptions"
  121. :key="dict.dictValue"
  122. :label="dict.dictLabel"
  123. :value="dict.dictValue"
  124. />
  125. </el-select> </el-form-item
  126. ></el-col> -->
  127. </el-row>
  128. <el-row>
  129. <el-col :span="16">
  130. <el-form-item
  131. label="合同描述:"
  132. prop="zfcDesc"
  133. >
  134. <el-input
  135. type="textarea"
  136. maxlength="100"
  137. style="width:250%"
  138. show-word-limit
  139. v-model="form.zfcDesc"
  140. placeholder="请输入合同描述"
  141. /> </el-form-item
  142. ></el-col>
  143. </el-row>
  144. <!-- 合同模板文件 -->
  145. <el-divider content-position="left">合同模板文件</el-divider>
  146. <el-form-item label="合同模板文件" style="margin-left: 100px">
  147. <el-upload
  148. ref="upload"
  149. class="upload-demo"
  150. action=""
  151. :http-request="httpRequest"
  152. :before-remove="beforeRemove"
  153. :on-preview="handleFileDownload"
  154. accept=".docx"
  155. multiple
  156. :limit="1"
  157. :on-exceed="handleExceed"
  158. :file-list="fileList"
  159. :auto-upload="true"
  160. style="width:800px"
  161. >
  162. <el-button slot="trigger" size="small" type="primary"
  163. >点击选择</el-button
  164. >
  165. <!-- <el-button
  166. style="margin-left: 10px"
  167. size="small"
  168. type="success"
  169. @click="submitUpload"
  170. >上传到服务器</el-button
  171. > -->
  172. </el-upload>
  173. </el-form-item>
  174. </el-form>
  175. <!-- 保存 -->
  176. <div class="footer" style="margin-top: 260px; float: right">
  177. <el-button type="info" @click="cancel">取消</el-button>
  178. <el-button type="success" @click="submitForm">提交</el-button>
  179. </div>
  180. </div>
  181. </template>
  182. <script>
  183. import { getContract,updateContract } from "@/api/service/contract/contract";
  184. import { listCompany } from "@/api/common/company";
  185. import { uploadFileNew } from "@/api/common/file";
  186. import { getToken } from "@/utils/auth";
  187. export default {
  188. name: "editContract",
  189. components: {},
  190. data() {
  191. return {
  192. disabled: false,
  193. // 日期范围
  194. dateRange: [],
  195. //选中数据
  196. chooseList: [],
  197. // 选中数组
  198. ids: [],
  199. // 弹出层标题
  200. title: "",
  201. // 总条数
  202. total: 0,
  203. // 是否显示弹出层
  204. open: false,
  205. // 资方列表
  206. companyList: [],
  207. //附件地址
  208. fileList:[],
  209. //数据字典
  210. typeOptions: [],
  211. subjectOptions: [],
  212. nodeOptions: [],
  213. nodeList:[],
  214. // 表单参数
  215. form: {},
  216. queryParams: {
  217. pageNum: 1,
  218. pageSize: 10,
  219. },
  220. options: [],
  221. value: [],
  222. loading: false,
  223. // 表单校验
  224. rules: {
  225. zfcName: [
  226. {
  227. required: true,
  228. message: "合同模板名称",
  229. trigger: ["blur", "change"],
  230. },
  231. ],
  232. zfcManagementId: [
  233. {
  234. required: true,
  235. message: "资金方不能为空",
  236. trigger: ["blur", "change"],
  237. },
  238. ],
  239. zfcType: [
  240. {
  241. required: true,
  242. message: "合同类型",
  243. trigger: ["blur", "change"],
  244. },
  245. ],
  246. zfcSubject: [
  247. {
  248. required: true,
  249. message: "签署主体",
  250. trigger: ["blur", "change"],
  251. },
  252. ],
  253. },
  254. };
  255. },
  256. created() {
  257. const zfcId = this.$route.params && this.$route.params.zfcId;
  258. this.reset();
  259. this.getCompanyList();
  260. //this.getList();
  261. this.getDicts("zc_zfc_type").then((response) => {
  262. this.typeOptions = response.data;
  263. });
  264. this.getDicts("zc_zfc_subject").then((response) => {
  265. this.subjectOptions = response.data;
  266. });
  267. getContract(zfcId).then((response) =>{
  268. this.form = response.data.zcFinanceContract;
  269. this.form.createTime = this.parseTime(new Date(response.data.zcFinanceContract.createTime),'{y}-{m}-{d} {h}:{m}:{s}');
  270. var zfcCode = this.form.zfcNode.split(",")
  271. var signKeyword = this.form.zfcSignKeyword.split(",")
  272. for(var i=0;i<zfcCode.length;i++){
  273. this.chooseList.push({zfcCode:zfcCode[i],zfcSignKeyword:signKeyword[i]});
  274. }
  275. this.getDicts("zc_zfc_node").then((response) => {
  276. this.nodeOptions = response.data;
  277. for(let i=0;i<this.nodeOptions.length;i++){
  278. var k = 0;
  279. for(let j=0;j<this.chooseList.length;j++){
  280. if(this.nodeOptions[i].dictValue == this.chooseList[j].zfcCode){
  281. this.nodeList.push({zfcNode:this.nodeOptions[i].dictLabel,zfcCode:this.nodeOptions[i].dictValue,zfcSignKeyword:this.chooseList[j].zfcSignKeyword})
  282. k =1;
  283. }
  284. }
  285. if(k != 1){
  286. this.nodeList.push({zfcNode:this.nodeOptions[i].dictLabel,zfcCode:this.nodeOptions[i].dictValue,zfcSignKeyword:''})
  287. }
  288. }
  289. }).then(()=>{
  290. console.log(this.nodeList,"<=========")
  291. this.chooseList.forEach((item) => {
  292. this.nodeList.forEach((row) => {
  293. if (row.zfcCode == item.zfcCode) {
  294. this.$nextTick(() => {
  295. this.$refs.tableContract &&
  296. this.$refs.tableContract.toggleRowSelection(row, true);
  297. });
  298. }
  299. });
  300. });
  301. });
  302. this.userName = response.data.nickName;
  303. const pfiFileName = response.data.fileName;
  304. const fileUrl = response.data.fileUrl;
  305. const fileId = response.data.fileId;
  306. if (fileUrl && fileId && pfiFileName != null){
  307. this.fileList.push({name:pfiFileName, url: fileUrl, uid: fileId });
  308. }
  309. var state = this.form.zfpStatus;
  310. if(state == '01'){
  311. this.disabled = true ;
  312. }
  313. const type = "03";
  314. const zfcManagementId = this.form.zfcManagementId;
  315. listCompany(type,zfcManagementId).then(response =>{
  316. this.companyList = response.data;
  317. })
  318. });
  319. },
  320. activated() {
  321. this.reset();
  322. //this.getList();
  323. },
  324. methods: {
  325. /** 查询资方 */
  326. getCompanyList(){
  327. const type = "03";
  328. listCompany(type).then(response =>{
  329. this.companyList = response.data;
  330. })
  331. },
  332. reset(){
  333. this.form = {
  334. };
  335. this.resetForm("form");
  336. },
  337. // 取消按钮
  338. cancel() {
  339. this.reset();
  340. this.$store.dispatch("tagsView/delView", this.$route);
  341. this.$router.go(-1);
  342. this.open = false;
  343. },
  344. // 多选框选中数据
  345. handleSelectionChange(val) {
  346. this.chooseList = val;
  347. },
  348. /** 上传图片 */
  349. submitUpload() {
  350. this.$refs.upload.submit();
  351. },
  352. //文件移除提示
  353. beforeRemove(file, fileList) {
  354. // return this.$confirm(`确定移除 ${file.name}?`);
  355. for(let i = 0;i< this.fileList.length;i++){
  356. if(file.uid == this.fileList[i].uid){
  357. this.fileList.splice(i, 1);
  358. break;
  359. }
  360. }
  361. },
  362. handleExceed(files, fileList) {
  363. this.$message.warning(`当前限制选择 1 个文件`);
  364. },
  365. beforeUpload(files){
  366. var testmsg=files.name.substring(files.name.lastIndexOf('.')+1);
  367. const extension2 = testmsg === 'docx'
  368. if(!extension2){
  369. this.$message.warning(`请选择word文档`);
  370. }
  371. return extension2;
  372. },
  373. //手动上传文件触发
  374. httpRequest(param) {
  375. let fileObj = param.file; // 相当于input里取得的files
  376. let fd = new FormData(); // FormData 对象
  377. fd.append("file", fileObj); // 文件对象
  378. fd.append("fileType", "04"); // 类型:文件
  379. const loading = this.$loading({
  380. lock: true,
  381. text: "Loading",
  382. spinner: "el-icon-loading",
  383. background: "rgba(0, 0, 0, 0.7)",
  384. });
  385. uploadFileNew(fd).then((response) => {
  386. if (response) {
  387. this.fileList.push({name:response.fileName,uid : response.fileId,url:response.url+'/'+getToken()})
  388. this.msgSuccess("上传成功");
  389. loading.close();
  390. }
  391. }).catch((response) =>{
  392. if(!response){
  393. this.$message.warning(`上传失败`);
  394. }
  395. loading.close();
  396. });
  397. },
  398. /* 下载 */
  399. handleFileDownload(sfcFile){
  400. this.$confirm('是否确认下载'+sfcFile.name+'附件?', "警告", {
  401. confirmButtonText: '确定',
  402. cancelButtonText: '取消',
  403. type: "warning"
  404. }).then(function() {
  405. if(sfcFile.name.substr(-3) == "pdf"){
  406. if(sfcFile.url.indexOf("getPdf") != -1){
  407. sfcFile.url = sfcFile.url.replace("getPdf","getBytes");
  408. }
  409. window.open(sfcFile.url+'/'+getToken());
  410. }else{
  411. var a = document.createElement('a');
  412. var event = new MouseEvent('click');
  413. a.download = sfcFile.name;
  414. a.href = sfcFile.url+'/'+getToken();
  415. a.dispatchEvent(event);
  416. }
  417. })
  418. },
  419. /** 保存按钮 */
  420. submitForm() {
  421. this.$refs["form"].validate((valid) => {
  422. this.form.nodeList = this.chooseList;
  423. if(!this.fileList.length){
  424. this.$message({
  425. message: '请上传附件!',
  426. type: 'warning'
  427. });
  428. return;
  429. };
  430. console.log(this.form)
  431. this.form.zfcFile = this.fileList;
  432. if (valid) {
  433. const loading = this.$loading({
  434. lock: true,
  435. text: "Loading",
  436. spinner: "el-icon-loading",
  437. background: "rgba(0, 0, 0, 0.7)",
  438. });
  439. updateContract(this.form)
  440. .then((response) => {
  441. loading.close();
  442. this.msgSuccess("修改成功");
  443. this.$store.dispatch("tagsView/delView", this.$route);
  444. this.$router.go(-1);
  445. })
  446. .catch((response) => {
  447. loading.close();
  448. });
  449. }
  450. });
  451. },
  452. // submitData() {
  453. // this.open = false;
  454. // },
  455. /* // 将数字金额转换为大写金额 */
  456. },
  457. };
  458. </script>
  459. <style>
  460. .single-select-table thead .el-table-column--selection .cell {
  461. display: none;
  462. }
  463. </style>