DailyFeeedit.vue 19 KB

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