addContract.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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 :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. accept=".docx"
  154. multiple
  155. :limit="1"
  156. :on-exceed="handleExceed"
  157. :before-upload="beforeUpload"
  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 { addContract } 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: "addContract",
  189. components: {},
  190. data() {
  191. return {
  192. nodeList:[],
  193. disabled: true,
  194. //选中数据
  195. chooseList: [],
  196. // 选中数组
  197. ids: [],
  198. //附件地址
  199. fileList:[],
  200. // 弹出层标题
  201. title: "",
  202. invoiceTitle: "",
  203. // 总条数
  204. total: 0,
  205. totalCustomer: 0,
  206. totalContract: 0,
  207. totalProject: 0,
  208. // 是否显示弹出层
  209. open: false,
  210. // 资方列表
  211. companyList: [],
  212. //合同列表
  213. contractList: [],
  214. content: [],
  215. //发票列表
  216. typeOptions: [],
  217. subjectOptions: [],
  218. nodeOptions: [],
  219. // 表单参数
  220. form: {},
  221. queryParams: {
  222. pageNum: 1,
  223. pageSize: 10,
  224. pifName: null,
  225. pifId: null,
  226. pifContractId: null,
  227. },
  228. queryParamsInvoice: {
  229. pageNum: 1,
  230. pageSize: 10,
  231. dateTime: [],
  232. pvfProjectId: null,
  233. pvfContractId: null,
  234. pidCode: null,
  235. pvfTYPE: null,
  236. pvfInvoiceTitle: null,
  237. },
  238. options: [],
  239. value: [],
  240. loading: false,
  241. // 表单校验
  242. rules: {
  243. zfcName: [
  244. {
  245. required: true,
  246. message: "合同模板名称",
  247. trigger: ["blur", "change"],
  248. },
  249. ],
  250. zfcManagementId: [
  251. {
  252. required: true,
  253. message: "资金方不能为空",
  254. trigger: ["blur", "change"],
  255. },
  256. ],
  257. zfcType: [
  258. {
  259. required: true,
  260. message: "合同类型",
  261. trigger: ["blur", "change"],
  262. },
  263. ],
  264. zfcSubject: [
  265. {
  266. required: true,
  267. message: "签署主体",
  268. trigger: ["blur", "change"],
  269. },
  270. ],
  271. },
  272. };
  273. },
  274. created() {
  275. this.reset();
  276. this.getCompanyList();
  277. this.getDicts("zc_zfc_type").then((response) => {
  278. this.typeOptions = response.data;
  279. });
  280. this.getDicts("zc_zfc_node").then((response) => {
  281. this.nodeOptions = response.data;
  282. for(let i=0;i<this.nodeOptions.length;i++){
  283. this.nodeList.push({zfcNode:this.nodeOptions[i].dictLabel,zfcCode:this.nodeOptions[i].dictValue})
  284. }
  285. console.log(this.nodeList);
  286. });
  287. this.getDicts("zc_zfc_subject").then((response) => {
  288. this.subjectOptions = response.data;
  289. });
  290. },
  291. activated() {
  292. this.reset();
  293. },
  294. methods: {
  295. // 上传
  296. /** 查询资方 */
  297. getCompanyList() {
  298. const type = "03";
  299. listCompany(type).then((response) => {
  300. this.companyList = response.data;
  301. });
  302. },
  303. change(val) {
  304. if (val <= 14) {
  305. this.$set(this.form, "zfpShortestPeriod", "14");
  306. }
  307. return;
  308. },
  309. // 多选框选中数据
  310. handleSelectionChange(val) {
  311. this.chooseList = val;
  312. },
  313. /** 上传图片 */
  314. submitUpload() {
  315. this.$refs.upload.submit();
  316. },
  317. //文件移除提示
  318. beforeRemove(file, fileList) {
  319. // return this.$confirm(`确定移除 ${file.name}?`);
  320. for(let i = 0;i< this.fileList.length;i++){
  321. if(file.uid == this.fileList[i].uid){
  322. this.fileList.splice(i, 1);
  323. break;
  324. }
  325. }
  326. },
  327. handleExceed(files, fileList) {
  328. this.$message.warning(`当前限制选择 1 个文件`);
  329. },
  330. beforeUpload(files){
  331. var testmsg=files.name.substring(files.name.lastIndexOf('.')+1);
  332. const extension2 = testmsg === 'docx'
  333. if(!extension2){
  334. this.$message.warning(`请选择word文档`);
  335. }
  336. return extension2;
  337. },
  338. //手动上传文件触发
  339. httpRequest(param) {
  340. let fileObj = param.file; // 相当于input里取得的files
  341. let fd = new FormData(); // FormData 对象
  342. fd.append("file", fileObj); // 文件对象
  343. fd.append("fileType", "04"); // 类型:文件
  344. const loading = this.$loading({
  345. lock: true,
  346. text: "Loading",
  347. spinner: "el-icon-loading",
  348. background: "rgba(0, 0, 0, 0.7)",
  349. });
  350. uploadFileNew(fd).then((response) => {
  351. if (response) {
  352. this.fileList.push({name:response.fileName,uid : response.fileId,url:response.url+'/'+getToken()})
  353. this.msgSuccess("上传成功");
  354. loading.close();
  355. }
  356. }).catch((response) =>{
  357. if(!response){
  358. this.$message.warning(`上传失败`);
  359. }
  360. loading.close();
  361. });
  362. },
  363. // 多选框选中数据
  364. handleCurrentChange(val) {
  365. // this.currentRow = val;
  366. // this.open = false;
  367. },
  368. reset() {
  369. this.form = {
  370. };
  371. this.resetForm("form");
  372. },
  373. /* ---------------------------------------------------------------------- */
  374. // 取消按钮
  375. cancel() {
  376. this.reset();
  377. this.$store.dispatch("tagsView/delView", this.$route);
  378. this.$router.go(-1);
  379. this.open = false;
  380. },
  381. /** 保存按钮 */
  382. submitForm() {
  383. this.$refs["form"].validate((valid) => {
  384. this.form.nodeList = this.chooseList;
  385. if(!this.fileList.length){
  386. this.$message({
  387. message: '请上传合同模板!',
  388. type: 'warning'
  389. });
  390. return;
  391. };
  392. this.form.zfcFile = this.fileList;
  393. console.log(this.form);
  394. if (valid) {
  395. const loading = this.$loading({
  396. lock: true,
  397. text: "Loading",
  398. spinner: "el-icon-loading",
  399. background: "rgba(0, 0, 0, 0.7)",
  400. });
  401. addContract(this.form)
  402. .then((response) => {
  403. loading.close();
  404. this.msgSuccess("新增成功");
  405. this.$store.dispatch("tagsView/delView", this.$route);
  406. this.$router.go(-1);
  407. })
  408. .catch((response) => {
  409. loading.close();
  410. });
  411. }
  412. });
  413. },
  414. // submitData() {
  415. // this.open = false;
  416. // },
  417. /* // 将数字金额转换为大写金额 */
  418. },
  419. };
  420. </script>
  421. <style>
  422. .single-select-table thead .el-table-column--selection .cell {
  423. display: none;
  424. }
  425. </style>