applyAgainCost.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <el-dialog
  3. :close-on-click-modal="false"
  4. :close-on-press-escape="false"
  5. :title="dialogTitle"
  6. :visible.sync="dialogVisible"
  7. top="50px"
  8. width="75%"
  9. :before-close="beforeClose"
  10. >
  11. <div class="tabsdom">
  12. <el-tabs v-model="activeName" @tab-click="handleClick">
  13. <el-tab-pane label="报支申请" name="first">
  14. <el-form
  15. ref="elformData"
  16. :model="form"
  17. :rules="rules"
  18. class="cost_form"
  19. label-width="125px"
  20. style="width: 100%;padding: 5px"
  21. >
  22. <el-card shadow="always" style="padding: 15px 5px 5px 15px">
  23. <el-row :gutter="10">
  24. <el-col :span="24">
  25. <el-form-item label="关联项目" prop="proId">
  26. <el-select v-model="form.proId" filterable placeholder="关联项目名称">
  27. <el-option
  28. v-for="item in ProjectData"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value"
  32. >
  33. <span style="float: left">{{ item.label }}</span>
  34. <span style="float: right; color: #8492a6; font-size: 13px">{{
  35. item.custname
  36. }}</span>
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <el-card class="pdtopbottom16 mb25 pdtop16px">
  43. <span class="moneydetails">
  44. <!-- <span style="color: red">*</span>-->
  45. 费用明细
  46. </span>
  47. <el-row :gutter="10" class="eltype">
  48. <el-col :span="4" class="col-txt txtc"><span>费用类型</span></el-col>
  49. <el-col :span="4" class="col-txt txtc">
  50. 金额(元)
  51. </el-col>
  52. <el-col :span="4" class="col-txt txtc">
  53. 发票号
  54. </el-col>
  55. <el-col :span="10" class="col-txt txtc">
  56. 单据
  57. </el-col>
  58. </el-row>
  59. <el-row
  60. v-for="(item,index) in form.applyUseMoneyDetailListString"
  61. :gutter="10"
  62. class="eltype"
  63. >
  64. <el-col :span="4">
  65. <el-select
  66. size="small"
  67. v-model="item.feeType"
  68. filterable placeholder="请选择"
  69. style="width: 100%"
  70. >
  71. <el-option
  72. v-for="item in dc_data.BUDGET_FY"
  73. :key="item.value"
  74. :label="item.label"
  75. :value="item.value"
  76. />
  77. </el-select>
  78. </el-col>
  79. <el-col :span="4">
  80. <el-input-number
  81. v-model="item.feeMoney"
  82. :controls="false"
  83. size="small"
  84. controls-position="right"
  85. placeholder="请填写金额,如0.1"
  86. style="width: 100%"
  87. />
  88. </el-col>
  89. <el-col :span="4">
  90. <el-input
  91. v-model="item.fileNumber"
  92. :controls="false"
  93. size="small"
  94. :disabled="item.fileList==0"
  95. controls-position="right"
  96. placeholder="请输入发票号(需上传发票)"
  97. style="width: 100%"
  98. />
  99. </el-col>
  100. <el-col :span="10" class="col-input">
  101. <!-- {{ item.fileList }}-->
  102. <el-upload
  103. :action="$constant.BASE_URI+'/FileController/upload'"
  104. :file-list="item.fileList"
  105. :http-request="(params)=>{uploadFile(params,index)}"
  106. :limit="5"
  107. :multiple="false"
  108. :show-file-list="false"
  109. class="upload-demo"
  110. style="width: 30%;float: left;margin-left: 42px"
  111. >
  112. <el-button size="small" style="font-size: 14px" type="text">
  113. 上传发票
  114. <img
  115. src="./fapiaoicon.png"
  116. style="margin-left: 5px;position: absolute;top: 13.5px;"
  117. width="24px"
  118. />
  119. </el-button>
  120. </el-upload>
  121. <el-radio-group
  122. v-model="item.fileType"
  123. style="margin-left: 30px;"
  124. @input="changeFileType($event,index)"
  125. >
  126. <el-radio v-if="false" :label="1">上传发票</el-radio>
  127. <el-radio :label="2">发票后补</el-radio>
  128. <el-radio :label="3">无发票</el-radio>
  129. </el-radio-group>
  130. </el-col>
  131. <el-col :span="1" class="col-txt txtc">
  132. &nbsp;
  133. <el-button
  134. v-if="index!=0"
  135. circle
  136. icon="el-icon-minus"
  137. @click="deleteRow(index)"
  138. />
  139. </el-col>
  140. <el-col :span="1" class="col-txt txtc">
  141. <el-button
  142. v-if="index==form.applyUseMoneyDetailListString.length-1"
  143. circle
  144. icon="el-icon-plus"
  145. type="primary"
  146. @click="addListRow()"
  147. />
  148. </el-col>
  149. <el-col :span="13">&nbsp;</el-col>
  150. <el-col :span="11">
  151. <div v-for="(file,i) in item.fileList" v-if="item.fileList.length>0"
  152. style="margin: 0 0px 0px 45px;"
  153. >
  154. <div>
  155. <a :href="file.url">{{ file.name }}</a>
  156. <span class="el-upload-list__item-actions">
  157. <i class="el-icon-delete" @click="handlePictureRemove(i,file,item.fileList)"/>
  158. </span>
  159. </div>
  160. </div>
  161. </el-col>
  162. </el-row>
  163. <div class="feeMoneyTotal">
  164. <div style="float: right">共计金额(元):{{ feeMoneyTotal() }}</div>
  165. </div>
  166. </el-card>
  167. <el-row :gutter="10">
  168. <el-col :span="24">
  169. <el-form-item label="用途" prop="useReasons">
  170. <el-input v-model="form.useReasons" type="textarea"/>
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="24">
  174. <el-form-item label="收款单位(人)" prop="payeeName">
  175. <el-input v-model="form.payeeName"></el-input>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="12">
  179. <el-form-item label="开户银行">
  180. <el-input v-model="form.bankName"></el-input>
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="12">
  184. <el-form-item label="银行账户" label-width="125px">
  185. <el-input v-model="form.bankAccountNum" filterable placeholder="请输入银行账户"/>
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="24">
  189. <el-form-item label="抄送">
  190. <user-select
  191. :default-select="selectList"
  192. :multiple="true"
  193. class="cclist"
  194. @selectValue="parentMethod"
  195. />
  196. </el-form-item>
  197. </el-col>
  198. </el-row>
  199. </el-card>
  200. </el-form>
  201. </el-tab-pane>
  202. <el-tab-pane label="流程图 " name="second">
  203. <costCanvas ref="costCanvas"/>
  204. </el-tab-pane>
  205. </el-tabs>
  206. </div>
  207. <div slot="footer">
  208. <el-button @click="dialogVisible = false">取 消</el-button>
  209. <el-button :loading="loading" type="primary" @click="confirmSubmit()">确 定</el-button>
  210. </div>
  211. </el-dialog>
  212. </template>
  213. <script>
  214. import { upload } from '@/static/utils/channel'
  215. import Base from '@/views/base/base'
  216. import BaseData from '@/views/base/baseData'
  217. import UserSelect from '@/views/components/UserSelect'
  218. import costCanvas from '@/views/workflow/components/myProcess/costCanvas.vue'
  219. export default {
  220. name: 'ApplyPay',
  221. mixins: [Base, BaseData],
  222. components: {
  223. upload, UserSelect, costCanvas
  224. },
  225. data() {
  226. return {
  227. row: {},
  228. rules: {
  229. proId: [{ required: true, message: '请选择关联项目', trigger: 'change' }],
  230. useReasons: [{ required: true, message: '请输入费用报支用途', trigger: 'blur' }],
  231. payeeName: [{ required: true, message: '请输入收款单位(人)', trigger: 'blur' }],
  232. password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
  233. },
  234. selectList: [],
  235. loading: false,
  236. dc_key: ['ORDER_STATUS', 'PAY_TYPE', 'BUDGET_FY'],
  237. ProjectData: [],
  238. dialogTitle: '费用报支申请-重新发起',
  239. dialogVisible: false,
  240. form: {
  241. applyUseMoneyDetailListString: [{ fileList: [], fileType: 1 }]
  242. },
  243. activeName: 'first'
  244. }
  245. },
  246. mounted() {
  247. this.initDict(this.dc_key).then((res) => {
  248. this.initProject({ /* signstatus: '2,3'*/ })
  249. })
  250. },
  251. methods: {
  252. handleClick(tab, event) {
  253. this.canVasStatus = false
  254. if (this.activeName == 'second') {
  255. this.canVasStatus = true
  256. this.$nextTick(() => {
  257. this.$refs.costCanvas.createNodeCanvas(this.row)
  258. })
  259. }
  260. },
  261. beforeClose() {
  262. this.form = {
  263. applyUseMoneyDetailListString: []
  264. }
  265. this.dialogVisible = false
  266. this.activeName = 'first'
  267. this.$forceUpdate()
  268. },
  269. feeMoneyTotal() {
  270. let feeMoneyTotal = 0
  271. for (let i = 0; i < this.form.applyUseMoneyDetailListString.length; i++) {
  272. feeMoneyTotal += this.form.applyUseMoneyDetailListString[i].feeMoney
  273. }
  274. this.form.feeMoneyTotal = feeMoneyTotal
  275. return feeMoneyTotal.toFixed(2)
  276. },
  277. changeFileType(e, i) {
  278. if (e != 1) {
  279. this.form.applyUseMoneyDetailListString[i].fileList = []
  280. }
  281. this.$forceUpdate()
  282. },
  283. parentMethod(val) {
  284. if (val.length > 0) {
  285. this.form.ccList = val.join(',')
  286. }
  287. },
  288. handlePictureRemove(i, file, fileList) {
  289. fileList.splice(i, 1)
  290. let copyFileList = [...fileList]
  291. fileList = copyFileList
  292. this.form.applyUseMoneyDetailListString = this.form.applyUseMoneyDetailListString.map((e) => {
  293. return e
  294. })
  295. },
  296. uploadFile(params, i) {
  297. upload(params, true).then((res) => {
  298. this.form.applyUseMoneyDetailListString[i].fileList.push(res)
  299. this.form.applyUseMoneyDetailListString[i].fileType = 1
  300. this.$message.success('上传成功')
  301. this.$forceUpdate()
  302. })
  303. },
  304. baseRequest1(prefix, opUrl, postData) {
  305. return this.$channel.globleRequest(prefix, opUrl, postData, 'project task')
  306. },
  307. async confirmSubmit() {
  308. for (let i = 0; i < this.form.applyUseMoneyDetailListString.length; i++) {
  309. if (this.form.applyUseMoneyDetailListString[i].fileType == 1
  310. &&
  311. (!this.form.applyUseMoneyDetailListString[i].fileList
  312. ||
  313. this.form.applyUseMoneyDetailListString[i].fileList.length == 0)) {
  314. this.$message.warning(`请上传费用明细中第${i + 1}行的发票文件`)
  315. return
  316. }
  317. if (this.form.applyUseMoneyDetailListString[i].fileType == 1 && this.form.applyUseMoneyDetailListString[i].fileNumber.length == 0) {
  318. this.$message.warning(`请检查费用明细中第${i + 1}行,并输入发票号`)
  319. return
  320. }
  321. }
  322. this.$refs.elformData.validate(async(valid) => {
  323. if (valid) {
  324. let formData = { ...this.form }
  325. formData.applyUseMoneyDetailListString.forEach((e) => {
  326. if (e.fileList) {
  327. e.fileDataIds = e.fileList.map((e) => {
  328. return e.data
  329. }).join()
  330. }
  331. })
  332. let params = formData.applyUseMoneyDetailListString.map((e) => {
  333. return {
  334. fileType: e.fileType,
  335. fileDataIds: e.fileDataIds,
  336. feeMoney: e.feeMoney,
  337. feeType: e.feeType,
  338. fileNumber: e.fileNumber
  339. }
  340. })
  341. let submitData = { ...formData, applyUseMoneyDetailListString: JSON.stringify(params) }
  342. this.loading = true
  343. const { data } = await this.baseRequest1('ApplyUseMoneyController', 'addApplyUseMoneyAgain', submitData)
  344. this.loading = false
  345. if (data.code == 200) {
  346. this.form = { applyUseMoneyDetailListString: [{ fileType: 1, fileList: [] }] }
  347. this.dialogVisible = false
  348. this.$refs.elformData.clearValidate()
  349. this.$message.success('流程发起成功')
  350. this.$emit('getData')
  351. }
  352. }
  353. })
  354. },
  355. async setVisible(status, row) {
  356. this.row = row
  357. this.activeName = 'first'
  358. const { data } = await this.baseRequest1('ApplyUseMoneyController', 'getInfoByFlowMainId', { flowMainId: row.id })
  359. this.form = data
  360. this.form.applyUseMoneyDetailListString = data.applyUseMoneyDetailList
  361. for (const e of this.form.applyUseMoneyDetailListString) {
  362. if (e.fileDataIds.length > 0) {
  363. // e.fileList = e.fileDataIds.split(',')
  364. const { data: fileTaoTaoList } = await this.baseRequest1('FileZtController', 'findFileInfoByIds/' + e.fileDataIds, '')
  365. e.fileList = fileTaoTaoList.data.map((file) => {
  366. return {
  367. url: this.$constant.BASE_URI + '/FileController/download/' + file.id,
  368. name: file.fileName,
  369. data: file.id,
  370. uid: new Date().getTime()
  371. }
  372. })
  373. } else {
  374. e.fileList = []
  375. }
  376. }
  377. // $constant.BASE_URI+'/FileController/download/'
  378. this.selectList = data.flowMainCcList.map((e) => {
  379. return e.ccUser
  380. })
  381. console.log(this.selectList)
  382. this.dialogVisible = status
  383. this.row = row
  384. delete this.form.flowMainCcList
  385. delete this.form.applyUseMoneyDetailList
  386. },
  387. addListRow() {
  388. const _this = this
  389. _this.form.applyUseMoneyDetailListString.push({
  390. feeType: this.dc_data.BUDGET_FY[0].value,
  391. fileList: [],
  392. fileType: 1,
  393. feeMoney: 0,
  394. fileNumber: ''
  395. })
  396. },
  397. deleteRow(index) {
  398. this.form.applyUseMoneyDetailListString.splice(index, 1)
  399. }
  400. }
  401. }
  402. </script>
  403. <style lang="scss">
  404. .cclist {
  405. .col-input {
  406. padding: 0;
  407. }
  408. }
  409. .mb25 {
  410. margin-bottom: 25px;
  411. }
  412. .pdtopbottom16 {
  413. padding: 0px 16px;
  414. }
  415. .pdtop16px {
  416. padding-top: 16px;
  417. }
  418. .cost_form {
  419. .col-input {
  420. font-weight: 400;
  421. }
  422. .el-form-item__label .moneydetails {
  423. text-align: right;
  424. font-size: 16px;
  425. font-family: 微软雅黑;
  426. padding-right: 10px;
  427. line-height: 40px;
  428. word-break: keep-all;
  429. white-space: nowrap;
  430. color: #606266;
  431. text-rendering: optimizeLegibility;
  432. font-weight: 400;
  433. }
  434. .moneydetails {
  435. text-align: right;
  436. font-size: 16px;
  437. font-family: 微软雅黑;
  438. padding-right: 10px;
  439. word-break: keep-all;
  440. white-space: nowrap;
  441. color: #606266;
  442. text-rendering: optimizeLegibility;
  443. font-weight: 400;
  444. }
  445. .moneydetails:before {
  446. content: "*";
  447. color: #ff4949;
  448. }
  449. }
  450. .txtc {
  451. text-align: center
  452. }
  453. .ml5 {
  454. margin-left: 5px;
  455. }
  456. .eltype {
  457. margin-bottom: 5px;
  458. }
  459. .tabsdom {
  460. .el-tabs__header {
  461. text-align: center !important;
  462. width: 139px !important;
  463. text-align: center !important;
  464. display: block !important;
  465. margin: auto !important;
  466. margin-bottom: 15px !important;
  467. }
  468. .el-tabs__nav-wrap::after {
  469. display: none;
  470. }
  471. .el-upload {
  472. width: 100%;
  473. }
  474. }
  475. .feeMoneyTotal {
  476. width: 100%;
  477. height: 14px;
  478. font-size: 14px;
  479. font-weight: 400;
  480. color: #1890FF;
  481. margin-top: 31px;
  482. margin-bottom: 13px;
  483. }
  484. </style>