applyAgainCost.vue 16 KB

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