applyProductPrice.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <view class="apply-credit">
  3. <view class="title">{{ $t('approval.formInfo') }}</view>
  4. <view class="form-wrap">
  5. <u-form labelPosition="left" :model="form" :rules="rules" ref="form1" labelWidth='90'>
  6. <!-- 流程编码 -->
  7. <u-form-item :label="$t('approval.approvalCode')" borderBottom prop="wfCode">
  8. <u-input readonly v-model="form.wfCode" border="none" />
  9. </u-form-item>
  10. <!-- 流程标题 -->
  11. <u-form-item :label="$t('approval.approvalTitle')" borderBottom prop="flowTitle">
  12. <u-input :readonly="isCheckView" v-model="form.flowTitle" border="none"
  13. :placeholder="$t('base.common.placeholderI') + $t('approval.approvalTitle')" />
  14. </u-form-item>
  15. <!-- 紧急程度 -->
  16. <u-form-item :label="$t('approval.urgency')" borderBottom prop="flowUrgent" @click="showPopup('flowUrgent')">
  17. <u-input readonly @change="resetFlow('flowUrgent')" v-model="textForm.flowUrgent" border="none"
  18. :placeholder="$t('base.common.placeholderS') + $t('approval.urgency')" />
  19. </u-form-item>
  20. <!-- 调价日期 -->
  21. <u-form-item :label="$t('approval.priceDate')" borderBottom prop="setDate" @click="showSetDateCalendar = true">
  22. <u-input readonly v-model="form.setDate" border="none"
  23. :placeholder="$t('base.common.placeholderS') + $t('approval.priceDate')" />
  24. </u-form-item>
  25. <!-- 调价类型 -->
  26. <u-form-item :label="$t('approval.priceType')" borderBottom prop="priceType" @click="showPopup('priceType')">
  27. <u-input readonly v-model="textForm.priceType" border="none"
  28. :placeholder="$t('base.common.placeholderS') + $t('approval.priceType')" />
  29. </u-form-item>
  30. <!-- 执行时间 -->
  31. <u-form-item :label="$t('approval.carryOutDate')" borderBottom prop="beginDate" @click="showBeginDate = true">
  32. <u-input readonly v-model="form.beginDate" border="none"
  33. :placeholder="$t('base.common.placeholderS') + $t('approval.carryOutDate')" />
  34. </u-form-item>
  35. <!-- 结束时间 -->
  36. <u-form-item :label="$t('report.endData')" borderBottom prop="finishDate" @click="showFinishDate = true">
  37. <u-input readonly v-model="form.finishDate" border="none"
  38. :placeholder="$t('base.common.placeholderS') + $t('report.endData')" />
  39. </u-form-item>
  40. <!-- 调价明细 -->
  41. <u-form-item :label="$t('approval.priceDetail')" borderBottom prop="details" @click="toPage" v-if="!isCheckView">
  42. <u-input readonly border="none" :placeholder="$t('approval.priceDetail')" />
  43. <u-icon slot="right" name="arrow-right"></u-icon>
  44. </u-form-item>
  45. <!-- 备注 -->
  46. <u-form-item label="备注" borderBottom prop="remark">
  47. <u-input :readonly="isCheckView" type="textarea" v-model="form.remark" border="none" placeholder="备注信息" />
  48. </u-form-item>
  49. </u-form>
  50. </view>
  51. <view class="title">{{ $t('approval.priceDetail') }}</view>
  52. <view class="details-wrap">
  53. <template v-if="form.details.length">
  54. <view class="details-line details-title" :style="'width:' + 222 * 4 + 'rpx'">
  55. <span v-if="form.priceType == '101'">{{ $t('order.companyName') }}</span>
  56. <span v-if="form.priceType == '102'">{{ $t('order.region') }}</span>
  57. <span>{{ $t('order.materialName') }}</span>
  58. <span>{{ $t('approval.latestPrice') }}</span>
  59. <span>{{ $t('approval.adjustedPrice') }}</span>
  60. </view>
  61. <view v-for="(item, index) in form.details" :key="index" class="details-line" :style="'width:' + 222 * 4 + 'rpx'">
  62. <span v-if="form.priceType == '101'">{{ item.companyName }}</span>
  63. <span v-if="form.priceType == '102'">{{ item.blockName }}</span>
  64. <span class="item">{{ item.materialName }}</span>
  65. <span>{{ item.lastPrice || '' }}</span>
  66. <span>{{ item.price || '' }}</span>
  67. </view>
  68. </template>
  69. <template v-else>
  70. <u-empty mode="list" text='设置调价明细' icon="https://cdn.uviewui.com/uview/empty/list.png">
  71. </u-empty>
  72. </template>
  73. </view>
  74. <view class="title">{{ $t('approval.approvalInfo') }}</view>
  75. <view class="flow-wrap">
  76. <u-steps direction="column" :current="currentIndex">
  77. <u-steps-item v-for="item, index in flowList" :key="index" :title="item.title"
  78. :desc="item.content + (item.handleOpinion ? ` (${item.handleOpinion})` : '')">
  79. <span slot="time" class="time">{{ item.time }}</span>
  80. </u-steps-item>
  81. </u-steps>
  82. </view>
  83. <view class="btn-wrap" v-if="!isCheckView">
  84. <button type="primary" color='#4680F9' @click="submit('form1')">{{ $t('base.common.submit') }}</button>
  85. </view>
  86. <!-- 紧急程度 -->
  87. <PopupSelect ref="flowUrgent" kind="flowUrgent" :option="flowUrgentOptions" @onConfirm="onConfirm" />
  88. <!-- 调价类型 -->
  89. <PopupSelect ref="priceType" kind="priceType" :option="priceTypeOptions" @onConfirm="onConfirm" />
  90. <!-- 调价日期 -->
  91. <u-calendar color="#4680F9" round='25' :show="showSetDateCalendar" @confirm="onSetDateConfirm"
  92. @close="showSetDateCalendar = false">
  93. </u-calendar>
  94. <!-- 执行时间 -->
  95. <u-datetime-picker :show="showBeginDate" v-model="beginDate" @confirm="beginDateConfirm" :maxDate="4102329599000"
  96. @cancel="showBeginDate = false" mode="datetime"></u-datetime-picker>
  97. <!-- 结束时间 -->
  98. <u-datetime-picker :show="showFinishDate" v-model="finishDate" @confirm="finishDateConfirm"
  99. @cancel="showFinishDate = false" :maxDate="4102329599000" mode="datetime"></u-datetime-picker>
  100. <u-toast ref="loadingToast" />
  101. </view>
  102. </template>
  103. <script>
  104. import PopupSelect from '../../components/popup-select/index'
  105. import {
  106. getApprovalFlow,
  107. BillNumber,
  108. createApproval,
  109. getApprovalInfo,
  110. getApprovalFlowInfo
  111. } from "../../api/approval"
  112. import dayjs from 'dayjs'
  113. export default {
  114. components: {
  115. PopupSelect,
  116. },
  117. data() {
  118. return {
  119. isCheckView: false,
  120. enCode: 'applyProductPrice',
  121. id: '',
  122. flowId: '',
  123. userInfo: {},
  124. showSetDateCalendar: false,
  125. showBeginDate: false,
  126. showFinishDate: false,
  127. beginDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  128. finishDate: '2099-12-30 23:59:00', //结束日期
  129. flow: {},
  130. flowList: [],
  131. currentIndex: 0,
  132. form: {
  133. flowId: '',
  134. wfCode: '',
  135. // billNo: '',
  136. flowTitle: '',
  137. flowUrgent: 1,
  138. finishDate: '2099-12-30 23:59:00', //结束日期
  139. setDate: dayjs().format('YYYY-MM-DD'), //登记日期
  140. beginDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),//执行日期
  141. remark: undefined, //备注
  142. details: [],
  143. priceType: '',
  144. },
  145. formcondition: {
  146. flowUrgent: false, //紧急程度
  147. },
  148. textForm: {
  149. flowUrgent: this.$t('approval.ordinary'), //紧急程度
  150. priceType: '',
  151. },
  152. rules: {
  153. flowTitle: [
  154. { required: true, message: this.$t('base.common.placeholderI') + this.$t('approval.approvalTitle') },
  155. ],
  156. flowUrgent: [
  157. { required: true, message: this.$t('base.common.placeholderS') + this.$t('approval.urgency') },
  158. ],
  159. setDate: [{ required: true, message: this.$t('base.common.placeholderS') + this.$t('approval.priceDate'), trigger: "change" }],
  160. beginDate: [{ required: true, message: this.$t('base.common.placeholderS') + this.$t('approval.carryOutDate'), trigger: "change" }],
  161. finishDate: [{ required: true, message: this.$t('base.common.placeholderS') + this.$t('report.endData'), trigger: "change" }],
  162. priceType: [{ required: true, message: this.$t('base.common.placeholderS') + this.$t('approval.priceType'), trigger: "change" }],
  163. details: [{
  164. required: true,
  165. message: "领用明细不能为空",
  166. validator: (rule, value, callback) => {
  167. if (this.form.details.length) {
  168. callback()
  169. } else {
  170. callback(new Error("调价信息不能为空"))
  171. }
  172. }
  173. }],
  174. },
  175. flowUrgentOptions: [
  176. { text: this.$t('approval.ordinary'), value: 1 },
  177. { text: this.$t('approval.urgent'), value: 2 },
  178. { text: this.$t('approval.important'), value: 3 },
  179. ],
  180. priceTypeOptions: [
  181. { text: this.$t('order.notSelected'), value: null },
  182. { text: '合同价格', value: '101' },
  183. { text: '区域价格', value: '102' },
  184. ],
  185. applicantOptions: [{ text: this.$t('order.noData'), value: null }], //申请人员选项
  186. clientOptions: [{ text: this.$t('order.noData'), value: null }], //授信客户选项
  187. };
  188. },
  189. onLoad(options) {
  190. this.form.flowId = options.flowId
  191. if (options.id) {
  192. this.isCheckView = true
  193. this.id = options.id
  194. this.getApprovalFlowInfo()
  195. } else {
  196. this.userInfo = uni.getStorageSync("userInfo");
  197. this.getOptions()
  198. this.getApprovalFlow()
  199. }
  200. },
  201. methods: {
  202. //获取详情
  203. getApprovalFlowInfo() {
  204. let encode = this.enCode[0].toUpperCase() + this.enCode.slice(1)
  205. getApprovalInfo(encode, this.id).then(res => {
  206. if (res.data.code == 200) {
  207. this.form = res.data.data
  208. let data = res.data.data
  209. this.textForm.flowUrgent = data.flowUrgent == 1 ? this.$t('approval.ordinary') : (data.flowUrgent == 2 ? this.$t('approval.urgent') : this.$t('approval.important')) //紧急程度
  210. this.textForm.priceType = data.priceType == '101' ? '合同价格' : '挂牌价格'
  211. }
  212. })
  213. getApprovalFlowInfo(this.id).then(res => {
  214. if (res.data.code == 200) {
  215. let flow = JSON.parse(res.data.data.flowTaskInfo.flowTemplateJson)
  216. this.flow = flow
  217. this.forFlowObj(flow)
  218. this.flowList.forEach((item, index) => {
  219. res.data.data.flowTaskOperatorRecordList.forEach(i => {
  220. if (i.nodeCode == item.nodeId) {
  221. item.time = i.handleTime || ''
  222. item.handleOpinion = i.handleOpinion || ''
  223. this.currentIndex = index
  224. }
  225. })
  226. res.data.data.flowTaskNodeList.forEach(i => {
  227. if (i.nodeCode == item.nodeId) {
  228. item.content = i.userName || item.content
  229. }
  230. })
  231. })
  232. }
  233. })
  234. },
  235. //提交审批
  236. submit(ref) {
  237. let _this = this
  238. this.$refs[ref].validate().then(() => {
  239. let key = this.enCode[0].toUpperCase() + this.enCode.slice(1)
  240. this.$refs.loadingToast.show({
  241. type: "loading",
  242. message: _this.$t('base.common.loading'),
  243. duration: '100000',
  244. })
  245. createApproval(key, this.form).then(res => {
  246. if (res.data.code == 200) {
  247. this.$refs.loadingToast.hide()
  248. uni.showModal({
  249. title: _this.$t('settings.tips'),
  250. content: _this.$t('approval.creditApprovalSuccess'),
  251. showCancel: false,
  252. success: ({ confirm, cancel }) => {
  253. if (confirm) {
  254. uni.navigateBack({ delta: 1 })
  255. }
  256. }
  257. })
  258. } else {
  259. this.$refs.loadingToast.hide()
  260. uni.showModal({
  261. title: _this.$t('settings.tips'),
  262. content: res.data.msg || _this.$t('approval.creditApprovalFail'),
  263. showCancel: false,
  264. })
  265. }
  266. }).catch(res => {
  267. _this.$refs.loadingToast.hide()
  268. console.log("调用异常返回、", res);
  269. });
  270. })
  271. },
  272. //获取审批流程
  273. getApprovalFlow() {
  274. getApprovalFlow(this.form.flowId).then(res => {
  275. if (res.data.code == 200) {
  276. this.form.flowTitle = this.userInfo.username + '的' + res.data.data.fullName
  277. let flow = JSON.parse(res.data.data.flowTemplateJson)
  278. this.flow = flow
  279. console.log(this.flow);
  280. this.forFlowObj(flow)
  281. }
  282. })
  283. },
  284. toPage() {
  285. this.$refs.form1.validateField('priceType', (res) => {
  286. if (res.length) {
  287. uni.showToast({
  288. title: res[0].message,
  289. icon: 'none',
  290. })
  291. } else {
  292. uni.navigateTo({ url: `/subpages/approval/price?priceType=${this.form.priceType}` })
  293. }
  294. })
  295. },
  296. //获取选项
  297. getOptions() {
  298. //流程编码
  299. BillNumber(this.enCode, dayjs().format('YYYY-MM-DD')).then(res => {
  300. if (res.data.code == 0) {
  301. this.form.wfCode = res.data.msg
  302. }
  303. })
  304. },
  305. //确定选择
  306. onConfirm(value, kind) {
  307. console.log(value, kind, '-----------------');
  308. if (value.value) {
  309. this.form[kind] = value.value
  310. this.textForm[kind] = value.text
  311. } else {
  312. this.form[kind] = ''
  313. this.textForm[kind] = ''
  314. }
  315. },
  316. //根据条件重新设置流程
  317. resetFlow(value) {
  318. if (this.isCheckView) {
  319. return
  320. }
  321. if (this.formcondition[value]) {
  322. this.flowList = []
  323. if (this.form[value]) {
  324. this.forFlowObj(this.flow)
  325. }
  326. }
  327. },
  328. //选择调价日期
  329. onSetDateConfirm(date) {
  330. this.form.setDate = dayjs(date).format('YYYY-MM-DD');
  331. this.showSetDateCalendar = false;
  332. },
  333. //选项格式
  334. formatOption(data) {
  335. let arr = []
  336. data.forEach(item => {
  337. arr.push(
  338. {
  339. text: item.name || item.label,
  340. value: item.value || item.id || item.userId
  341. }
  342. )
  343. })
  344. if (arr.length) {
  345. arr.unshift({ text: this.$t('order.notSelected'), value: null })
  346. } else {
  347. arr.unshift({ text: this.$t('order.noData'), value: null })
  348. }
  349. return arr
  350. },
  351. //循环对象
  352. forFlowObj(flow) {
  353. this.flowList.push(
  354. {
  355. title: flow.properties.title,
  356. content: flow.content,
  357. nodeId: flow.nodeId,
  358. time: '',
  359. handleOpinion: "",
  360. }
  361. )
  362. if (flow.conditionNodes && flow.conditionNodes.length) {
  363. flow.conditionNodes.forEach(item => {
  364. let math = item.properties.conditions
  365. if (this.eval(math)) {
  366. this.flowList.push(
  367. {
  368. title: item.properties.title,
  369. content: item.content,
  370. nodeId: item.nodeId,
  371. time: '',
  372. handleOpinion: "",
  373. }
  374. )
  375. this.forFlowObj(item.childNode)
  376. }
  377. })
  378. }
  379. if (flow.childNode) {
  380. this.forFlowObj(flow.childNode)
  381. }
  382. },
  383. beginDateConfirm(time) {
  384. this.form.beginDate = dayjs(time.value).format('YYYY-MM-DD HH:mm:ss')
  385. this.showBeginDate = false
  386. },
  387. finishDateConfirm(time) {
  388. this.form.finishDate = dayjs(time.value).format('YYYY-MM-DD HH:mm:ss')
  389. this.showFinishDate = false
  390. },
  391. //显示选择
  392. showPopup(refs) {
  393. if (this.isCheckView) {
  394. return
  395. }
  396. this.$refs[refs].showPicker = true
  397. },
  398. //计算方法
  399. eval(conditions) {
  400. let boo = false
  401. let booList = []
  402. conditions.forEach((item, index) => {
  403. switch (item.symbol) {
  404. case '>=':
  405. booList.push(this.form[item.field] >= Number(item.filedValue))
  406. if (index != conditions.length - 1) {
  407. booList.push(item.logic)
  408. }
  409. break;
  410. case '>':
  411. booList.push(this.form[item.field] > Number(item.filedValue))
  412. if (index != conditions.length - 1) {
  413. booList.push(item.logic)
  414. }
  415. break;
  416. case '==':
  417. booList.push(this.form[item.field] == Number(item.filedValue))
  418. if (index != conditions.length - 1) {
  419. booList.push(item.logic)
  420. }
  421. break;
  422. case '<=':
  423. booList.push(this.form[item.field] <= Number(item.filedValue))
  424. if (index != conditions.length - 1) {
  425. booList.push(item.logic)
  426. }
  427. break;
  428. case '<':
  429. booList.push(this.form[item.field] < Number(item.filedValue))
  430. if (index != conditions.length - 1) {
  431. booList.push(item.logic)
  432. }
  433. break;
  434. case '<>':
  435. booList.push(this.form[item.field] != Number(item.filedValue))
  436. if (index != conditions.length - 1) {
  437. booList.push(item.logic)
  438. }
  439. break;
  440. }
  441. this.formcondition[item.field] = true
  442. })
  443. let booList2 = []
  444. if (booList.length > 1) {
  445. booList.forEach((item, index) => {
  446. if (index % 2 != 0) {
  447. switch (item) {
  448. case "&&":
  449. booList2.push(booList[index - 1] && booList[index + 1])
  450. break;
  451. }
  452. } else {
  453. if (booList[index + 1] != "&&" && booList[index - 1] != "&&") {
  454. booList2.push(item)
  455. }
  456. }
  457. })
  458. } else {
  459. boo = booList[0]
  460. }
  461. if (booList2.length > 1) {
  462. booList2.forEach(item => {
  463. if (item) {
  464. boo = true
  465. }
  466. })
  467. } else if (booList2.length == 1) {
  468. boo = booList2[0]
  469. }
  470. return boo
  471. },
  472. }
  473. };
  474. </script>
  475. <style lang="scss" scoped>
  476. @import '../../common/css/apply.scss';
  477. </style>