DailyFeeedit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div v-loading="fullscreenLoading" class="dailyedit-box">
  3. <div class="dailyedit-title">
  4. 新增日常费用付款申请款项
  5. </div>
  6. <div style="text-align: right;margin-bottom: 20px;">
  7. <el-button v-if="editid&&userid==21||userid==22" size="small" type="primary" @click="PostDelDailyPaymentAudit(1)">审核通过</el-button>
  8. <el-button v-if="editid&&userid==21||userid==22" size="small" type="primary" @click="PostDelDailyPaymentAudit(2)">审核不通过</el-button>
  9. <el-button size="small" type="primary" @click="submitForm('ruleForm')">保 存</el-button>
  10. <el-button size="small" @click="resetForm('ruleForm')">返 回</el-button>
  11. </div>
  12. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm">
  13. <div class="dailyedit-set">
  14. <el-form-item label="类型标识:" label-width="85px" prop="transferation">
  15. <el-select :disabled="thesame" @change="trans()" v-model="ruleForm.transferation" placeholder="请选择转账标识">
  16. <el-option v-for="(item,index) in Transferlogo" :key="index" :label="item.name" :value="item.id"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="转账标识:" prop="identification" label-width="85px">
  20. <el-select :disabled="banned" v-model="ruleForm.identification" placeholder="请选择费用类型">
  21. <el-option v-for="(item,index) in identificationset" :key="index" :label="item.name" :value="item.id"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="费用类型:" prop="type" label-width="85px">
  25. <el-select :disabled="thesame" @change="typechange()" v-model="ruleForm.type" placeholder="请选择费用类型">
  26. <el-option v-for="(item,index) in typeset" :key="index" :label="item.name" :value="item.id"></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="费用名称:" prop="name" label-width="85px">
  30. <el-select :disabled="bannedtype" v-model="ruleForm.name" placeholder="请选择费用名称">
  31. <el-option v-for="(item,index) in nameset" :key="index" :label="item.name" :value="item.id"></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="申请公司:" prop="company" label-width="85px">
  35. <el-select :disabled="thesame" v-model="ruleForm.company" placeholder="请选择申请公司">
  36. <el-option v-for="(item,index) in companyset" :key="index" :label="item.companyName" :value="item.id"></el-option>
  37. </el-select>
  38. </el-form-item>
  39. </div>
  40. <el-form-item label="申请说明:" label-width="85px" prop="desc">
  41. <el-input :disabled="thesame" type="textarea" v-model="ruleForm.desc"></el-input>
  42. </el-form-item>
  43. <div class="dailyfrom-title">
  44. <div>录入具体费用</div>
  45. <el-form-item>
  46. <el-button size="mini" @click="AddForm()" type="primary">新 增</el-button>
  47. </el-form-item>
  48. </div>
  49. <div class="items-form">
  50. <div v-for="(item,index) in itemsArr" :key="index" class="items-li">
  51. <el-form :model="item" class="demo-form-inline" label-width="85px">
  52. <el-form-item label="费用项目:">
  53. <el-input :disabled="thesame" v-model="item.priceName" placeholder="费用项目名称"></el-input>
  54. </el-form-item>
  55. <el-form-item label="数量:">
  56. <template>
  57. <el-input-number :disabled="thesame" :min="1" v-model="item.quantity"></el-input-number>
  58. </template>
  59. </el-form-item>
  60. <el-form-item label="单价(CNY):">
  61. <el-input-number :disabled="thesame" :controls="false" v-model="item.price" :precision="2"></el-input-number>
  62. </el-form-item>
  63. <el-form-item label="小计(CNY):">
  64. <div class="sub-box">{{item.itemTotal=(item.quantity*item.price).toFixed(2)}}</div>
  65. </el-form-item>
  66. <el-form-item label="备注:">
  67. <el-input :disabled="thesame" v-model="item.remark" placeholder="备注"></el-input>
  68. </el-form-item>
  69. <el-form-item>
  70. <el-button
  71. size="mini"
  72. type="danger"
  73. :disabled="itemsArr.length<=1"
  74. @click="deleteRow(index,itemsArr )"><i class="el-icon-delete"></i></el-button>
  75. </el-form-item>
  76. </el-form>
  77. </div>
  78. </div>
  79. </el-form>
  80. </div>
  81. </template>
  82. <script>
  83. export default {
  84. // beforeRouteLeave(to, from, next) {
  85. // if(to.name=='DailyFeePayment'){
  86. // to.meta.keepAlive = true;
  87. // }
  88. // next()
  89. // },
  90. data(){
  91. return{
  92. editid:'',
  93. userid:'',
  94. token:'',
  95. banned:true,
  96. bannedtype:true,
  97. thesame:false,//是否能编辑标识
  98. ruleForm: {
  99. transferation:'',
  100. identification: '',
  101. type: '',
  102. name: '',
  103. company: '',
  104. desc:''
  105. },
  106. SumPrice:0,
  107. itemsArr:[
  108. {
  109. priceName:"",
  110. quantity:'',
  111. price:"",
  112. itemTotal:'',
  113. remark:""
  114. }
  115. ],
  116. rules: {
  117. transferation: [
  118. { required: true, message: '请选择转账标识', trigger: 'change' }
  119. ],
  120. identification: [
  121. { required: true, message: '请选择费用标识', trigger: 'change' }
  122. ],
  123. type: [
  124. { required: true, message: '请选择费用类型', trigger: 'change' }
  125. ],
  126. name: [
  127. { required: true, message: '请选择费用名称', trigger: 'change' }
  128. ],
  129. company: [
  130. { required: true, message: '请选择申请公司', trigger: 'change' }
  131. ],
  132. desc: [
  133. { required: true, message: '请填写申请说明', trigger: 'change' }
  134. ],
  135. },
  136. Transferlogo:[],//类型标识
  137. feeMarkSubTypeData:[],//转账标识ALL
  138. identificationset:[],//转账标识
  139. typeset:[],//费用类型
  140. feeSubTypeData:[],//费用名称ALL
  141. nameset:[],//费用名称
  142. companyset:[],//申请公司
  143. fullscreenLoading:false,//loading
  144. }
  145. },
  146. methods:{
  147. submitForm(formName) {
  148. this.$refs[formName].validate((valid) => {
  149. console.log(valid)
  150. if (valid) {
  151. console.log(this.itemsArr)
  152. var issubmit=true;
  153. for(var g=0;g<this.itemsArr.length;g++){
  154. if(this.itemsArr[g].itemTotal!=""&&this.itemsArr[g].price!=0&&this.itemsArr[g].priceName!=""&&this.itemsArr[g].quantity!=""){
  155. if(!this.thesame){
  156. //for(var k=0;k<this.itemsArr.length;k++){
  157. this.SumPrice+=Number(this.itemsArr[g].itemTotal)
  158. //}
  159. }else{
  160. this.$message({
  161. showClose: true,
  162. message: '本申请不是您建立的或已被审核,无法修改!',
  163. type: 'error'
  164. });
  165. issubmit=false;
  166. break;
  167. }
  168. }else{
  169. this.$message({
  170. showClose: true,
  171. message: '请检查录入具体费用是否填写完整!',
  172. type: 'error'
  173. });
  174. issubmit=false;
  175. break;
  176. }
  177. }
  178. if(issubmit){
  179. if(this.editid!=undefined){
  180. this.UpdateDailyPayment()
  181. }else{
  182. this.AddDailyPayment()
  183. }
  184. }
  185. } else {
  186. console.log('error submit!!');
  187. return false;
  188. }
  189. });
  190. },
  191. resetForm(formName) {
  192. // this.$refs[formName].resetFields();
  193. this.$router.push({ path: "/home/DailyFeePayment"});
  194. },
  195. AddForm(){
  196. if(this.thesame){
  197. this.$message({
  198. showClose: true,
  199. message: '本申请不是您建立的或已被审核,无法操作!',
  200. type: 'error'
  201. });
  202. return false
  203. }
  204. this.itemsArr.push(
  205. {priceName: '', quantity: '', price:'',itemTotal:'', remark: ''}
  206. )
  207. },
  208. deleteRow(index, rows) {
  209. if(this.thesame){
  210. this.$message({
  211. showClose: true,
  212. message: '本申请不是您建立的或已被审核,无法操作!',
  213. type: 'error'
  214. });
  215. return false
  216. }
  217. rows.splice(index, 1);
  218. },
  219. getTypeData() {
  220. var url = "/api/Financial/PostPageSearchDailyPaymentPriceTypeData"
  221. var that = this
  222. this.$axios({
  223. method: 'post',
  224. url: url,
  225. headers: {
  226. Authorization: 'Bearer ' + that.token
  227. },
  228. data: {
  229. portType: 1,
  230. }
  231. }).then(function (res) {
  232. console.log(res)
  233. if (res.data.code == 200) {
  234. that.Transferlogo=res.data.data.feeMarkTypeData;
  235. that.feeMarkSubTypeData=res.data.data.feeMarkSubTypeData;
  236. that.typeset=res.data.data.feeTypeData;
  237. that.feeSubTypeData=res.data.data.feeSubTypeData;
  238. that.companyset=res.data.data.companyNameData;
  239. }
  240. })
  241. },
  242. trans(){
  243. this.identificationset=[];
  244. this.ruleForm.identification='';
  245. for(var i=0;i<this.feeMarkSubTypeData.length;i++){
  246. if(this.feeMarkSubTypeData[i].sTid==this.ruleForm.transferation){
  247. this.identificationset.push(this.feeMarkSubTypeData[i]);
  248. }
  249. }
  250. if(this.identificationset.length==0){
  251. this.banned=true;
  252. }else{
  253. this.banned=false;
  254. }
  255. },
  256. typechange(){
  257. this.nameset=[];
  258. this.ruleForm.name='';
  259. console.log(this.feeSubTypeData)
  260. for(var i=0;i<this.feeSubTypeData.length;i++){
  261. if(this.feeSubTypeData[i].sTid==this.ruleForm.type){
  262. this.nameset.push(this.feeSubTypeData[i]);
  263. }
  264. }
  265. if(this.nameset.length==0){
  266. this.bannedtype=true;
  267. }else{
  268. this.bannedtype=false;
  269. }
  270. },
  271. AddDailyPayment(){
  272. var url = "/api/Financial/PostAddDailyPayment"
  273. var that = this
  274. var data={
  275. UserId:that.userid,
  276. Instructions:that.ruleForm.desc,
  277. SumPrice:that.SumPrice,
  278. TransferTypeId:that.ruleForm.identification,
  279. PriceTypeId:that.ruleForm.name,
  280. CompanyId:that.ruleForm.company,
  281. FeeContents:that.itemsArr
  282. }
  283. console.log(data)
  284. this.$axios({
  285. method: 'post',
  286. url: url,
  287. headers: {
  288. Authorization: 'Bearer ' + that.token
  289. },
  290. data: {
  291. PortType: 1,
  292. UserId:that.userid,
  293. Instructions:that.ruleForm.desc,
  294. SumPrice:that.SumPrice,
  295. TransferTypeId:that.ruleForm.identification,
  296. PriceTypeId:that.ruleForm.name,
  297. CompanyId:that.ruleForm.company,
  298. FeeContents:that.itemsArr
  299. }
  300. }).then(function (res) {
  301. console.log(res)
  302. if (res.data.code == 200) {
  303. that.$message({
  304. message: res.data.msg,
  305. type: 'success',
  306. offset:50
  307. });
  308. that.$router.push({ path: "/home/DailyFeePayment"});
  309. }
  310. })
  311. },
  312. UpdateDailyPayment(){
  313. var url = "/api/Financial/PostEditDailyPayment"
  314. var that = this
  315. this.$axios({
  316. method: 'post',
  317. url: url,
  318. headers: {
  319. Authorization: 'Bearer ' + that.token
  320. },
  321. data: {
  322. PortType: 1,
  323. Id:that.editid,
  324. UserId:that.userid,
  325. Instructions:that.ruleForm.desc,
  326. SumPrice:that.SumPrice,
  327. TransferTypeId:that.ruleForm.identification,
  328. PriceTypeId:that.ruleForm.name,
  329. CompanyId:that.ruleForm.company,
  330. FeeContents:that.itemsArr
  331. }
  332. }).then(function (res) {
  333. console.log(res)
  334. if (res.data.code == 200) {
  335. that.$message({
  336. message: res.data.msg,
  337. type: 'success',
  338. offset:50
  339. });
  340. that.$router.push({ path: "/home/DailyFeePayment"});
  341. }
  342. })
  343. },
  344. //审核
  345. PostDelDailyPaymentAudit(val){
  346. var url = "/api/Financial/PostDelDailyPaymentAudit"
  347. var that = this
  348. var auditType=0
  349. if(that.userid==21){
  350. auditType=2
  351. }
  352. if(that.userid==22){
  353. auditType=1
  354. }
  355. this.$axios({
  356. method: 'post',
  357. url: url,
  358. headers: {
  359. Authorization: 'Bearer ' + that.token
  360. },
  361. data: {
  362. id: that.editid,
  363. auditType:auditType,
  364. auditStatus:val
  365. }
  366. }).then(function (res) {
  367. if (res.data.code == 200) {
  368. that.$message({
  369. message: res.data.msg,
  370. type: 'success',
  371. offset:50
  372. });
  373. that.$router.push({ path: "/home/DailyFeePayment"});
  374. }else{
  375. that.$message.error(res.data.msg);
  376. }
  377. })
  378. },
  379. getPostSearchDailyPaymentInfo(){
  380. if(this.editid!=undefined){
  381. console.log("jing")
  382. this.fullscreenLoading=true;
  383. var url = "/api/Financial/PostSearchDailyPaymentInfo"
  384. var that = this
  385. this.$axios({
  386. method: 'post',
  387. url: url,
  388. headers: {
  389. Authorization: 'Bearer ' + that.token
  390. },
  391. data: {
  392. PortType: 1,
  393. id:that.editid
  394. }
  395. }).then(function (res) {
  396. console.log(res)
  397. if (res.data.code == 200) {
  398. that.itemsArr=res.data.data.feeContents;
  399. that.ruleForm.desc=res.data.data.instructions;
  400. setTimeout(function (){
  401. for(var a=0;a<that.feeMarkSubTypeData.length;a++){
  402. if(that.feeMarkSubTypeData[a].id==res.data.data.transferTypeId){
  403. that.ruleForm.transferation=that.feeMarkSubTypeData[a].sTid;
  404. }
  405. }
  406. that.trans();
  407. that.ruleForm.identification=res.data.data.transferTypeId;
  408. for(var b=0;b<that.feeSubTypeData.length;b++){
  409. if(that.feeSubTypeData[b].id==res.data.data.priceTypeId){
  410. that.ruleForm.type=that.feeSubTypeData[b].sTid;
  411. }
  412. }
  413. that.typechange()
  414. that.ruleForm.name=res.data.data.priceTypeId;
  415. that.fullscreenLoading=false;
  416. if(that.userid!=res.data.data.createUserId){
  417. that.thesame=true;
  418. }else if(res.data.data.fAudit!=0||res.data.data.mAudit!=0){
  419. that.thesame=true;
  420. }
  421. if(that.thesame==true){
  422. that.banned=true;
  423. that.bannedtype=true;
  424. }
  425. },1000);
  426. that.ruleForm.company=res.data.data.companyId;
  427. }
  428. })
  429. }
  430. }
  431. },
  432. mounted(){
  433. this.editid=this.$route.query.id;
  434. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  435. this.userid=JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
  436. this.getTypeData();
  437. this.getPostSearchDailyPaymentInfo();
  438. }
  439. }
  440. </script>
  441. <style>
  442. .dailyedit-box{
  443. background-color: #fff;
  444. padding: 10px;
  445. box-shadow: 0 0 5px #0005;
  446. border-radius: 10px;
  447. min-height: 800px;
  448. }
  449. .dailyedit-title{
  450. font-size: 17px;
  451. font-weight: 600;
  452. color: #555;
  453. margin-bottom: 30px;
  454. }
  455. .dailyedit-set{
  456. display: flex;
  457. justify-content: space-between;
  458. }
  459. .items-li{
  460. border-bottom: 1px #DCDFE6 solid;
  461. margin-bottom: 12px;
  462. }
  463. .items-li .demo-form-inline{
  464. display: flex;
  465. justify-content: space-between;
  466. }
  467. .dailyfrom-title{
  468. font-size: 14px;
  469. font-weight: 600;
  470. color: #555;
  471. margin-bottom: 30px;
  472. display: flex;
  473. align-items: center;
  474. justify-content: space-between;
  475. }
  476. .dailyfrom-title .el-form-item{
  477. margin: 0;
  478. }
  479. .items-li .el-form-item{
  480. margin-bottom: 10px;
  481. }
  482. .dailyedit-box .sub-box{
  483. -ms-user-select: none;
  484. font-family:"微软雅黑";
  485. -khtml-user-select: none;
  486. -webkit-user-select: none;
  487. -moz-user-select: none;
  488. user-select: none;
  489. background-color: #FFF;
  490. background-image: none;
  491. border-radius: 4px;
  492. border: 1px solid #DCDFE6;
  493. -webkit-box-sizing: border-box;
  494. box-sizing: border-box;
  495. color: #606266;
  496. display: inline-block;
  497. height: 40px;
  498. line-height: 40px;
  499. outline: 0;
  500. padding: 0 15px;
  501. -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
  502. transition: border-color .2s cubic-bezier(.645,.045,.355,1);
  503. width: 100%;
  504. }
  505. </style>