AuditApply_new.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <div style="width: 100%;height: 100%;padding: 5px">
  3. <el-form ref="auditForm" :model="auditForm" style="width: 100%;padding: 5px" :rules="auditRules">
  4. <el-row v-if="auditTarget == 'Project'">
  5. <el-col style="padding-bottom: 10px">
  6. <span class="card_title">基本信息</span>
  7. <el-card shadow="always">
  8. <el-row>
  9. <el-col :span="3" class="col-txt"><span>项目名称</span></el-col>
  10. <el-col :span="8" class="col-words">
  11. <span>{{ auditForm.proname }}</span>
  12. </el-col>
  13. <el-col :span="4" class="col-txt"><span>项目类型</span></el-col>
  14. <el-col :span="8" class="col-words">
  15. <span>{{ auditForm.protype }}</span>
  16. </el-col>
  17. </el-row>
  18. <el-row>
  19. <el-col :span="3" class="col-txt"><span>储备项目状态</span></el-col>
  20. <el-col :span="8" class="col-words">
  21. <span>{{ auditForm.prostatus }}</span>
  22. </el-col>
  23. <el-col :span="4" class="col-txt"><span>销售金额</span></el-col>
  24. <el-col :span="8" class="col-words">
  25. <span>{{ auditForm.presales }}</span>
  26. </el-col>
  27. </el-row>
  28. </el-card>
  29. </el-col>
  30. </el-row>
  31. <el-row v-if="transForm.default.formType == 'Contract'">
  32. <el-col style="padding-bottom: 10px">
  33. <span class="card_title">表单内容</span>
  34. <el-card shadow="always">
  35. <contract-detail ref="contract" :trans-form="transForm?transForm.default:null" :renewal="renewal" />
  36. </el-card>
  37. </el-col>
  38. </el-row>
  39. <el-row v-if="transForm.default.formType == 'AccPay'">
  40. <el-col style="padding-bottom: 10px">
  41. <span class="card_title">表单内容</span>
  42. <el-card shadow="always">
  43. <acc-pay ref="accPay" step="add" @baseRefresh="baseRefresh" />
  44. </el-card>
  45. </el-col>
  46. </el-row>
  47. <el-row v-if="transForm.default.formType == 'RealApproval'">
  48. <el-col style="padding-bottom: 10px">
  49. <span class="card_title">表单内容</span>
  50. <el-card shadow="always">
  51. <approval-form ref="realApprove" :trans-form="transForm?transForm.default:null" :renewal="renewal" />
  52. </el-card>
  53. </el-col>
  54. </el-row>
  55. <el-row>
  56. <el-col style="padding-bottom: 10px">
  57. <span class="card_title">申请内容</span>
  58. <el-card shadow="always" style="padding: 15px 5px 5px 15px">
  59. <el-row>
  60. <el-col :span="3" class="col-txt"><span>申请理由</span></el-col>
  61. <el-col :span="20" class="col-input">
  62. <el-form-item prop="reason">
  63. <el-input v-model="auditForm.reason" type="textarea" :rows="1">
  64. 启动储备项目
  65. </el-input>
  66. </el-form-item>
  67. </el-col>
  68. </el-row>
  69. <el-row>
  70. <el-col :span="3" class="col-txt"><span>备注说明</span></el-col>
  71. <el-col :span="20" class="col-input">
  72. <el-form-item>
  73. <el-input v-model="auditForm.comment" type="textarea" :rows="2" />
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. </el-card>
  78. </el-col>
  79. </el-row>
  80. <el-row>
  81. <el-col style="padding-bottom: 10px">
  82. <span class="card_title">审核相关</span>
  83. <el-card shadow="always" style="padding: 15px 5px 5px 15px">
  84. <el-row>
  85. <el-col :span="3" class="col-txt"><span>下一步审核人</span></el-col>
  86. <el-col :span="20" class="col-input">
  87. <el-form-item prop="currAuditBy">
  88. <user-select :default-select="selectList" :multiple="false" width="700" @selectValue="parentMethod" />
  89. <!-- <el-select v-model="auditForm.currAuditBy" placeholder="审核人">
  90. <el-option
  91. v-for="item in UserData"
  92. :key="item.value"
  93. :label="item.label"
  94. :value="item.value"
  95. />
  96. </el-select>-->
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <el-row>
  101. <el-col :span="3" class="col-txt"><span>创建日期</span></el-col>
  102. <el-col :span="8" class="col-input">
  103. <el-form-item>
  104. <el-input v-model="auditForm.applytimeStr" disabled />
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="3" class="col-txt"><span>创建人</span></el-col>
  108. <el-col :span="9" class="col-input">
  109. <el-form-item>
  110. <el-input v-model="auditForm.applyname" disabled />
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. </el-card>
  115. </el-col>
  116. </el-row>
  117. </el-form>
  118. <div class="el-dialog__footer">
  119. <el-button @click="handleClose()">取 消</el-button>
  120. <el-button type="primary" @click="handleCommit()">确 定</el-button>
  121. </div>
  122. </div>
  123. </template>
  124. <script>
  125. import channel from '../../../static/utils/channel'
  126. import Constant from '../../../static/utils/constant'
  127. import UserSelect from '@/views/components/UserSelect'
  128. import ContractDetail from '../../form/ctrForm'
  129. import ApprovalForm from '../../project/proApprovalForm'
  130. import AccPay from '../../form/apForm'
  131. import Base from '@/views/base/base'
  132. import BaseData from '@/views/base/baseData'
  133. export default {
  134. name: 'AuditApplyNew',
  135. components: {
  136. ContractDetail,
  137. AccPay,
  138. UserSelect,
  139. ApprovalForm
  140. },
  141. mixins: [Base, BaseData],
  142. props: {
  143. referenceId: {
  144. type: String,
  145. default: ''
  146. },
  147. auditTarget: {
  148. type: String,
  149. default: 'Project'
  150. },
  151. auditType: {
  152. type: Object,
  153. default: null
  154. },
  155. formType: {
  156. type: String,
  157. default: ''
  158. },
  159. // 续签标记(1:为续签)
  160. renewal: {
  161. type: String,
  162. default: ''
  163. }
  164. },
  165. data() {
  166. return {
  167. dc_key: ['PRO_TYPE'],
  168. enableStatus: '2',
  169. dc_project_status: Constant.dc_project_status,
  170. UserData: [],
  171. selectList: [],
  172. UserMap: {},
  173. auditForm: this.getProjectForm(),
  174. auditRules: {
  175. reason: [{ required: true, trigger: 'blur', message: '请输入申请原因' }],
  176. currAuditBy: [{ required: true, trigger: 'blur', message: '请选择下一步审核人' }]
  177. },
  178. transForm: this.getAuditForm(this.referenceId, this.auditType, true)
  179. }
  180. },
  181. watch: {
  182. referenceId: {
  183. deep: true,
  184. handler(val) {
  185. this.getData(val)
  186. }
  187. },
  188. // formType: {
  189. // deep: true,
  190. // handler(val) {
  191. // this.getData(this.referenceId)
  192. // }
  193. // },
  194. auditType: {
  195. deep: true,
  196. handler(val) {
  197. this.initForm(val)
  198. }
  199. }
  200. },
  201. mounted() {
  202. this.generateDcMap()
  203. this.initProType().then((res) => {
  204. this.$nextTick(() => {
  205. this.initUser().then(() => {
  206. this.getData(this.referenceId)
  207. this.initForm(this.auditType)
  208. })
  209. })
  210. })
  211. },
  212. methods: {
  213. parentMethod: function(val) {
  214. if (val.length > 0) {
  215. this.auditForm.currAuditBy = val.join(',')
  216. }
  217. },
  218. baseRefresh: function(val) {
  219. console.log(val)
  220. if (this.auditForm && val) {
  221. this.auditForm.proname = val.proName
  222. this.auditForm.custname = val.custName
  223. }
  224. },
  225. getData: function(val) {
  226. if (this.auditTarget === 'Project') {
  227. const postData = {
  228. id: val
  229. }
  230. channel.globleRequest('ProMainController', 'getById', postData, 'Project').then((res) => {
  231. if (res.data) {
  232. this.auditForm = this.getProjectForm(res.data)
  233. console.log(this.auditForm)
  234. }
  235. }).catch(() => {
  236. })
  237. } else if (this.auditTarget === 'OutSource') {
  238. this.auditForm = this.getAccPayForm()
  239. }
  240. },
  241. initForm: function(_auditType) {
  242. this.transForm = this.getAuditForm(this.referenceId, _auditType, true)
  243. },
  244. handleClose: function() {
  245. this.$emit('handleApplyClose')
  246. },
  247. /* 申请立项*/
  248. handleCommit: function() {
  249. this.$refs.auditForm.validate(valid => {
  250. if (valid) {
  251. // @Todo 流程启动,表单及类型
  252. this.auditApplyAdd(this.auditForm, this.auditType)
  253. } else {
  254. return false
  255. }
  256. })
  257. },
  258. auditApplyAdd: function(_val, _auditType) {
  259. const _this = this
  260. // 构建子表单数据
  261. const form = this.getAuditForm(_val.id, _auditType, false)
  262. // 构建目标表单数据
  263. let tId = _val.id
  264. if (this.auditTarget === 'OutSource') {
  265. tId = form.default.id
  266. }
  267. const target = this.getTarget(tId, _auditType)
  268. target.protype = _val.protype
  269. // 通用信息项
  270. const content = {
  271. proName: _val.proname,
  272. cusName: _val.custname
  273. }
  274. // 审批信息项
  275. const auditData = {
  276. auditType: _auditType.key,
  277. auditName: _auditType.name,
  278. auditTarget: this.$common.castString(target),
  279. auditForm: this.$common.castString(form),
  280. referenceId: _val.id,
  281. referenceContent: this.$common.castString(content),
  282. applyBy: _val.applyBy,
  283. currAuditBy: _val.currAuditBy,
  284. auditStatus: '0'
  285. }
  286. // 审批过程子项
  287. const auditDetailData = {
  288. reason: _val.reason,
  289. comment: _val.comment,
  290. auditedBy: _val.applyBy,
  291. nextTo: _val.currAuditBy,
  292. auditResult: '0'
  293. }
  294. channel.globleRequest('FlowAuditController', 'add', auditData, 'audit').then((res) => {
  295. if (res.data.auditId) {
  296. auditDetailData.auditId = res.data.auditId
  297. channel.globleRequest('FlowAuditDetailController', 'add', auditDetailData, 'audit detail')
  298. if (_this.transForm.default.formType === 'Contract') {
  299. _this.$refs.contract.addContract(form.default.id)
  300. } else if (_this.transForm.default.formType === 'AccPay') {
  301. _this.$refs.accPay.addAP(form.default.id)
  302. } else if (_this.transForm.default.formType === 'RealApproval') {
  303. _this.$refs.realApprove.addApproval(form.default.id)
  304. }
  305. if (target.processData) {
  306. channel.globleRequest(target.target, target.op, target.processData, target.target).then((res) => {
  307. _this.$emit('handleApplyCommit')
  308. })
  309. } else {
  310. _this.$emit('handleApplyCommit')
  311. }
  312. }
  313. }).catch(() => {
  314. _this.$emit('handleApplyCommit')
  315. })
  316. },
  317. getTarget: function(_id, _auditType) {
  318. const target = {
  319. id: _id
  320. }
  321. if (this.auditTarget === 'Project') {
  322. target.target = 'ProMainController'
  323. target.op = 'edit'
  324. if (_auditType.key === Constant.AUDIT_TYPE.PRO_APPROVE.key) {
  325. target.processData = {
  326. id: _id,
  327. validstatus: '1'
  328. }
  329. target.passData = {
  330. id: _id,
  331. validstatus: '2',
  332. validat: true
  333. }
  334. target.refuseData = {
  335. id: _id,
  336. validstatus: '3',
  337. validat: false
  338. }
  339. } else if (_auditType.key === Constant.AUDIT_TYPE.SIGN.key) {
  340. target.processData = {
  341. id: _id,
  342. signstatus: '1'
  343. }
  344. target.passData = {
  345. id: _id,
  346. signstatus: '3',
  347. signat: true
  348. }
  349. target.refuseData = {
  350. id: _id,
  351. signstatus: '0'
  352. }
  353. } else if (_auditType.key === Constant.AUDIT_TYPE.PRIOR_UP.key) {
  354. target.processData = {
  355. id: _id,
  356. signstatus: '1'
  357. }
  358. target.passData = {
  359. id: _id,
  360. signstatus: '2',
  361. signat: true
  362. }
  363. target.refuseData = {
  364. id: _id,
  365. signstatus: '0'
  366. }
  367. } else if (_auditType.key === Constant.AUDIT_TYPE.TENDER.key) {
  368. target.processData = {
  369. id: _id,
  370. bidstatus: '1'
  371. }
  372. target.passData = {
  373. id: _id,
  374. bidstatus: '2',
  375. bidat: true
  376. }
  377. target.refuseData = {
  378. id: _id,
  379. bidstatus: '0'
  380. }
  381. } else if (_auditType.key === Constant.AUDIT_TYPE.ENDING.key) {
  382. target.processData = {
  383. id: _id,
  384. enablestatus: '1'
  385. }
  386. target.passData = {
  387. id: _id,
  388. enablestatus: '2',
  389. endingat: true
  390. }
  391. target.refuseData = {
  392. id: _id,
  393. enablestatus: '0'
  394. }
  395. } else if (_auditType.key === Constant.AUDIT_TYPE.PRO_REAL_APPROVE.key) {
  396. target.processData = {
  397. id: _id,
  398. validstatus: '1'
  399. }
  400. target.passData = {
  401. id: _id,
  402. validstatus: '2',
  403. validat: true
  404. }
  405. target.refuseData = {
  406. id: _id,
  407. validstatus: '3',
  408. validat: false
  409. }
  410. }
  411. } else if (this.auditTarget === 'OutSource') {
  412. target.target = 'AccPayableController'
  413. target.op = 'edit'
  414. if (_auditType.key === Constant.AUDIT_TYPE.ACC_PAY.key) {
  415. target.passData = {
  416. id: _id,
  417. apStatus: '1'
  418. }
  419. target.refuseData = {
  420. id: _id,
  421. apStatus: '3'
  422. }
  423. }
  424. }
  425. return target
  426. },
  427. getAuditForm: function(_referenceId, _auditType, isAdd) {
  428. const form = {
  429. default: {
  430. referenceId: _referenceId,
  431. referenceType: this.auditTarget,
  432. isAdd: isAdd
  433. }
  434. }
  435. if (_auditType.key === Constant.AUDIT_TYPE.PRO_APPROVE.key) {
  436. form.default.controller = ''
  437. form.default.opQuery = ''
  438. form.default.formType = 'Approve'
  439. } else if (_auditType.key === Constant.AUDIT_TYPE.SIGN.key) {
  440. form.default.id = 'cid-' + String(new Date().getTime())
  441. form.default.controller = 'CtrMainController'
  442. form.default.opQuery = 'getById/' + form.default.id
  443. form.default.formType = 'Contract'
  444. form.default.opUpdate = 'edit'
  445. form.default.updateData = {
  446. valid: '1'
  447. }
  448. } else if (_auditType.key === Constant.AUDIT_TYPE.PRIOR_UP.key) {
  449. form.default.controller = ''
  450. form.default.opQuery = ''
  451. form.default.formType = 'Prior'
  452. } else if (_auditType.key === Constant.AUDIT_TYPE.TENDER.key) {
  453. form.default.controller = ''
  454. form.default.opQuery = ''
  455. form.default.formType = 'Tender'
  456. } else if (_auditType.key === Constant.AUDIT_TYPE.ENDING.key) {
  457. form.default.controller = ''
  458. form.default.opQuery = ''
  459. form.default.formType = 'Ending'
  460. } else if (_auditType.key === Constant.AUDIT_TYPE.ACC_PAY.key) {
  461. form.default.id = 'aid-' + String(new Date().getTime())
  462. form.default.controller = 'AccPayableController'
  463. form.default.opQuery = 'getById/' + form.default.id
  464. form.default.formType = 'AccPay'
  465. form.default.opUpdate = 'edit'
  466. form.default.updateData = {
  467. apStatus: '1'
  468. }
  469. } else if (_auditType.key === Constant.AUDIT_TYPE.PRO_REAL_APPROVE.key) {
  470. form.default.id = 'cid-' + String(new Date().getTime())
  471. form.default.controller = 'ProApprovalController'
  472. form.default.opQuery = 'getById/' + form.default.id
  473. form.default.formType = 'RealApproval'
  474. form.default.opUpdate = 'edit'
  475. form.default.updateData = {
  476. valid: '1'
  477. }
  478. }
  479. return form
  480. },
  481. getProjectForm: function(obj) {
  482. const currUser = this.$common.currUser()
  483. return {
  484. id: obj ? obj.id : '',
  485. proname: obj ? obj.proname : '',
  486. custname: obj ? obj.custname : '',
  487. protype: obj ? this.ProTypeMap[obj.protype] : '',
  488. prostatus: obj ? this.dc_map.dc_project_status[obj.prostatus] : '',
  489. presales: obj ? obj.presales : '',
  490. reason: '',
  491. comment: '',
  492. currAuditBy: '',
  493. applyBy: currUser ? currUser.id : '',
  494. applyname: currUser ? currUser.truename : '',
  495. applytimeStr: this.$common.transDate(new Date().getTime())
  496. }
  497. },
  498. getAccPayForm: function(obj) {
  499. const currUser = this.$common.currUser()
  500. return {
  501. id: '',
  502. proname: '',
  503. custname: '',
  504. reason: '',
  505. comment: '',
  506. currAuditBy: '',
  507. applyBy: currUser ? currUser.id : '',
  508. applyname: currUser ? currUser.truename : '',
  509. applytimeStr: this.$common.transDate(new Date().getTime())
  510. }
  511. },
  512. generateDcMap: function() {
  513. this.dc_map['dc_project_status'] = this.$common.transDcMap(Constant.dc_project_status)
  514. },
  515. /* 辅助相关*/
  516. initUser: function() {
  517. const _this = this
  518. this.UserData = []
  519. this.UserMap = {}
  520. return channel.globleRequest('SysUserExtendController', 'listAll', { status: '1' }, 'Pending Audit get user').then((res) => {
  521. if (res.data) {
  522. res.data.forEach(function(item) {
  523. const json = {
  524. label: item.truename,
  525. value: item.id
  526. }
  527. _this.UserData.push(json)
  528. _this.UserMap[json.value] = json.label
  529. })
  530. }
  531. }).catch(() => {
  532. })
  533. }
  534. }
  535. }
  536. </script>
  537. <style scoped>
  538. .audit-card {
  539. width: 70%;
  540. }
  541. .self {
  542. background: #95ec69;
  543. }
  544. .title {
  545. line-height: 28px;
  546. }
  547. .comment{
  548. line-height: 24px;
  549. }
  550. .text {
  551. font-size: 14px;
  552. }
  553. </style>
  554. <style>
  555. .el-card__header {
  556. padding: 10px 20px;
  557. }
  558. .el-card__body {
  559. padding: 10px 20px;
  560. }
  561. </style>