AuditApply_new.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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 AccPay from '../../form/apForm'
  130. import Base from '@/views/base/base'
  131. import BaseData from '@/views/base/baseData'
  132. export default {
  133. name: 'AuditApplyNew',
  134. components: {
  135. ContractDetail,
  136. AccPay,
  137. UserSelect,
  138. },
  139. mixins: [Base, BaseData],
  140. props: {
  141. referenceId: {
  142. type: String,
  143. default: ''
  144. },
  145. auditTarget: {
  146. type: String,
  147. default: 'Project'
  148. },
  149. auditType: {
  150. type: Object,
  151. default: null
  152. },
  153. formType: {
  154. type: String,
  155. default: ''
  156. },
  157. // 续签标记(1:为续签)
  158. renewal: {
  159. type: String,
  160. default: ''
  161. }
  162. },
  163. data() {
  164. return {
  165. dc_key: ['PRO_TYPE'],
  166. enableStatus: '2',
  167. dc_project_status: Constant.dc_project_status,
  168. UserData: [],
  169. selectList: [],
  170. UserMap: {},
  171. auditForm: this.getProjectForm(),
  172. auditRules: {
  173. reason: [{ required: true, trigger: 'blur', message: '请输入申请原因' }],
  174. currAuditBy: [{ required: true, trigger: 'blur', message: '请选择下一步审核人' }]
  175. },
  176. transForm: this.getAuditForm(this.referenceId, this.auditType, true)
  177. }
  178. },
  179. watch: {
  180. referenceId: {
  181. deep: true,
  182. handler(val) {
  183. this.getData(val)
  184. }
  185. },
  186. // formType: {
  187. // deep: true,
  188. // handler(val) {
  189. // this.getData(this.referenceId)
  190. // }
  191. // },
  192. auditType: {
  193. deep: true,
  194. handler(val) {
  195. this.initForm(val)
  196. }
  197. }
  198. },
  199. mounted() {
  200. this.generateDcMap()
  201. this.initProType().then((res) => {
  202. this.$nextTick(() => {
  203. this.initUser().then(() => {
  204. this.getData(this.referenceId)
  205. this.initForm(this.auditType)
  206. })
  207. })
  208. })
  209. },
  210. methods: {
  211. parentMethod: function(val) {
  212. if (val.length > 0) {
  213. this.auditForm.currAuditBy = val.join(',')
  214. }
  215. },
  216. baseRefresh: function(val) {
  217. console.log(val)
  218. if (this.auditForm && val) {
  219. this.auditForm.proname = val.proName
  220. this.auditForm.custname = val.custName
  221. }
  222. },
  223. getData: function(val) {
  224. if (this.auditTarget === 'Project') {
  225. const postData = {
  226. id: val
  227. }
  228. channel.globleRequest('ProMainController', 'getById', postData, 'Project').then((res) => {
  229. if (res.data) {
  230. this.auditForm = this.getProjectForm(res.data)
  231. console.log(this.auditForm)
  232. }
  233. }).catch(() => {
  234. })
  235. } else if (this.auditTarget === 'OutSource') {
  236. this.auditForm = this.getAccPayForm()
  237. }
  238. },
  239. initForm: function(_auditType) {
  240. this.transForm = this.getAuditForm(this.referenceId, _auditType, true)
  241. },
  242. handleClose: function() {
  243. this.$emit('handleApplyClose')
  244. },
  245. /* 申请立项*/
  246. handleCommit: function() {
  247. this.$refs.auditForm.validate(valid => {
  248. if (valid) {
  249. // @Todo 流程启动,表单及类型
  250. this.auditApplyAdd(this.auditForm, this.auditType)
  251. } else {
  252. return false
  253. }
  254. })
  255. },
  256. auditApplyAdd: function(_val, _auditType) {
  257. const _this = this
  258. // 构建子表单数据
  259. const form = this.getAuditForm(_val.id, _auditType, false)
  260. // 构建目标表单数据
  261. let tId = _val.id
  262. if (this.auditTarget === 'OutSource') {
  263. tId = form.default.id
  264. }
  265. const target = this.getTarget(tId, _auditType)
  266. target.protype = _val.protype
  267. // 通用信息项
  268. const content = {
  269. proName: _val.proname,
  270. cusName: _val.custname
  271. }
  272. // 审批信息项
  273. const auditData = {
  274. auditType: _auditType.key,
  275. auditName: _auditType.name,
  276. auditTarget: this.$common.castString(target),
  277. auditForm: this.$common.castString(form),
  278. referenceId: _val.id,
  279. referenceContent: this.$common.castString(content),
  280. applyBy: _val.applyBy,
  281. currAuditBy: _val.currAuditBy,
  282. auditStatus: '0'
  283. }
  284. // 审批过程子项
  285. const auditDetailData = {
  286. reason: _val.reason,
  287. comment: _val.comment,
  288. auditedBy: _val.applyBy,
  289. nextTo: _val.currAuditBy,
  290. auditResult: '0'
  291. }
  292. channel.globleRequest('FlowAuditController', 'add', auditData, 'audit').then((res) => {
  293. if (res.data.auditId) {
  294. auditDetailData.auditId = res.data.auditId
  295. channel.globleRequest('FlowAuditDetailController', 'add', auditDetailData, 'audit detail')
  296. if (_this.transForm.default.formType === 'Contract') {
  297. _this.$refs.contract.addContract(form.default.id)
  298. } else if (_this.transForm.default.formType === 'AccPay') {
  299. _this.$refs.accPay.addAP(form.default.id)
  300. } else if (_this.transForm.default.formType === 'RealApproval') {
  301. _this.$refs.realApprove.addApproval(form.default.id)
  302. }
  303. if (target.processData) {
  304. channel.globleRequest(target.target, target.op, target.processData, target.target).then((res) => {
  305. _this.$emit('handleApplyCommit')
  306. })
  307. } else {
  308. _this.$emit('handleApplyCommit')
  309. }
  310. }
  311. }).catch(() => {
  312. _this.$emit('handleApplyCommit')
  313. })
  314. },
  315. getTarget: function(_id, _auditType) {
  316. const target = {
  317. id: _id
  318. }
  319. if (this.auditTarget === 'Project') {
  320. target.target = 'ProMainController'
  321. target.op = 'edit'
  322. if (_auditType.key === Constant.AUDIT_TYPE.PRO_APPROVE.key) {
  323. target.processData = {
  324. id: _id,
  325. validstatus: '1'
  326. }
  327. target.passData = {
  328. id: _id,
  329. validstatus: '2',
  330. validat: true
  331. }
  332. target.refuseData = {
  333. id: _id,
  334. validstatus: '3',
  335. validat: false
  336. }
  337. } else if (_auditType.key === Constant.AUDIT_TYPE.SIGN.key) {
  338. target.processData = {
  339. id: _id,
  340. signstatus: '1'
  341. }
  342. target.passData = {
  343. id: _id,
  344. signstatus: '3',
  345. signat: true
  346. }
  347. target.refuseData = {
  348. id: _id,
  349. signstatus: '0'
  350. }
  351. } else if (_auditType.key === Constant.AUDIT_TYPE.PRIOR_UP.key) {
  352. target.processData = {
  353. id: _id,
  354. signstatus: '1'
  355. }
  356. target.passData = {
  357. id: _id,
  358. signstatus: '2',
  359. signat: true
  360. }
  361. target.refuseData = {
  362. id: _id,
  363. signstatus: '0'
  364. }
  365. } else if (_auditType.key === Constant.AUDIT_TYPE.TENDER.key) {
  366. target.processData = {
  367. id: _id,
  368. bidstatus: '1'
  369. }
  370. target.passData = {
  371. id: _id,
  372. bidstatus: '2',
  373. bidat: true
  374. }
  375. target.refuseData = {
  376. id: _id,
  377. bidstatus: '0'
  378. }
  379. } else if (_auditType.key === Constant.AUDIT_TYPE.ENDING.key) {
  380. target.processData = {
  381. id: _id,
  382. enablestatus: '1'
  383. }
  384. target.passData = {
  385. id: _id,
  386. enablestatus: '2',
  387. endingat: true
  388. }
  389. target.refuseData = {
  390. id: _id,
  391. enablestatus: '0'
  392. }
  393. } else if (_auditType.key === Constant.AUDIT_TYPE.PRO_REAL_APPROVE.key) {
  394. target.processData = {
  395. id: _id,
  396. validstatus: '1'
  397. }
  398. target.passData = {
  399. id: _id,
  400. validstatus: '2',
  401. validat: true
  402. }
  403. target.refuseData = {
  404. id: _id,
  405. validstatus: '3',
  406. validat: false
  407. }
  408. }
  409. } else if (this.auditTarget === 'OutSource') {
  410. target.target = 'AccPayableController'
  411. target.op = 'edit'
  412. if (_auditType.key === Constant.AUDIT_TYPE.ACC_PAY.key) {
  413. target.passData = {
  414. id: _id,
  415. apStatus: '1'
  416. }
  417. target.refuseData = {
  418. id: _id,
  419. apStatus: '3'
  420. }
  421. }
  422. }
  423. return target
  424. },
  425. getAuditForm: function(_referenceId, _auditType, isAdd) {
  426. const form = {
  427. default: {
  428. referenceId: _referenceId,
  429. referenceType: this.auditTarget,
  430. isAdd: isAdd
  431. }
  432. }
  433. if (_auditType.key === Constant.AUDIT_TYPE.PRO_APPROVE.key) {
  434. form.default.controller = ''
  435. form.default.opQuery = ''
  436. form.default.formType = 'Approve'
  437. } else if (_auditType.key === Constant.AUDIT_TYPE.SIGN.key) {
  438. form.default.id = 'cid-' + String(new Date().getTime())
  439. form.default.controller = 'CtrMainController'
  440. form.default.opQuery = 'getById/' + form.default.id
  441. form.default.formType = 'Contract'
  442. form.default.opUpdate = 'edit'
  443. form.default.updateData = {
  444. valid: '1'
  445. }
  446. } else if (_auditType.key === Constant.AUDIT_TYPE.PRIOR_UP.key) {
  447. form.default.controller = ''
  448. form.default.opQuery = ''
  449. form.default.formType = 'Prior'
  450. } else if (_auditType.key === Constant.AUDIT_TYPE.TENDER.key) {
  451. form.default.controller = ''
  452. form.default.opQuery = ''
  453. form.default.formType = 'Tender'
  454. } else if (_auditType.key === Constant.AUDIT_TYPE.ENDING.key) {
  455. form.default.controller = ''
  456. form.default.opQuery = ''
  457. form.default.formType = 'Ending'
  458. } else if (_auditType.key === Constant.AUDIT_TYPE.ACC_PAY.key) {
  459. form.default.id = 'aid-' + String(new Date().getTime())
  460. form.default.controller = 'AccPayableController'
  461. form.default.opQuery = 'getById/' + form.default.id
  462. form.default.formType = 'AccPay'
  463. form.default.opUpdate = 'edit'
  464. form.default.updateData = {
  465. apStatus: '1'
  466. }
  467. } else if (_auditType.key === Constant.AUDIT_TYPE.PRO_REAL_APPROVE.key) {
  468. form.default.id = 'cid-' + String(new Date().getTime())
  469. form.default.controller = 'ProApprovalController'
  470. form.default.opQuery = 'getById/' + form.default.id
  471. form.default.formType = 'RealApproval'
  472. form.default.opUpdate = 'edit'
  473. form.default.updateData = {
  474. valid: '1'
  475. }
  476. }
  477. return form
  478. },
  479. getProjectForm: function(obj) {
  480. const currUser = this.$common.currUser()
  481. return {
  482. id: obj ? obj.id : '',
  483. proname: obj ? obj.proname : '',
  484. custname: obj ? obj.custname : '',
  485. protype: obj ? this.ProTypeMap[obj.protype] : '',
  486. prostatus: obj ? this.dc_map.dc_project_status[obj.prostatus] : '',
  487. presales: obj ? obj.presales : '',
  488. reason: '',
  489. comment: '',
  490. currAuditBy: '',
  491. applyBy: currUser ? currUser.id : '',
  492. applyname: currUser ? currUser.truename : '',
  493. applytimeStr: this.$common.transDate(new Date().getTime())
  494. }
  495. },
  496. getAccPayForm: function(obj) {
  497. const currUser = this.$common.currUser()
  498. return {
  499. id: '',
  500. proname: '',
  501. custname: '',
  502. reason: '',
  503. comment: '',
  504. currAuditBy: '',
  505. applyBy: currUser ? currUser.id : '',
  506. applyname: currUser ? currUser.truename : '',
  507. applytimeStr: this.$common.transDate(new Date().getTime())
  508. }
  509. },
  510. generateDcMap: function() {
  511. this.dc_map['dc_project_status'] = this.$common.transDcMap(Constant.dc_project_status)
  512. },
  513. /* 辅助相关*/
  514. initUser: function() {
  515. const _this = this
  516. this.UserData = []
  517. this.UserMap = {}
  518. return channel.globleRequest('SysUserExtendController', 'listAll', { status: '1' }, 'Pending Audit get user').then((res) => {
  519. if (res.data) {
  520. res.data.forEach(function(item) {
  521. const json = {
  522. label: item.truename,
  523. value: item.id
  524. }
  525. _this.UserData.push(json)
  526. _this.UserMap[json.value] = json.label
  527. })
  528. }
  529. }).catch(() => {
  530. })
  531. }
  532. }
  533. }
  534. </script>
  535. <style scoped>
  536. .audit-card {
  537. width: 70%;
  538. }
  539. .self {
  540. background: #95ec69;
  541. }
  542. .title {
  543. line-height: 28px;
  544. }
  545. .comment{
  546. line-height: 24px;
  547. }
  548. .text {
  549. font-size: 14px;
  550. }
  551. </style>
  552. <style>
  553. .el-card__header {
  554. padding: 10px 20px;
  555. }
  556. .el-card__body {
  557. padding: 10px 20px;
  558. }
  559. </style>