approve.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <!-- 任务单 -->
  2. <template>
  3. <div class="order">
  4. <template v-if="!addOrUpdateVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
  6. <el-form-item label="业务类型">
  7. <el-select
  8. v-model="dataForm.businessType"
  9. placeholder="请选择">
  10. <el-option
  11. v-for="item in optionsType"
  12. :key="item.code"
  13. :label="item.value"
  14. :value="item.code">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="状态">
  19. <el-select
  20. v-model="dataForm.state"
  21. placeholder="请选择">
  22. <el-option
  23. v-for="item in optionsState"
  24. :key="item.code"
  25. :label="item.value"
  26. :value="item.code">
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="申请日期">
  31. <el-date-picker
  32. v-model="dataForm.createTime"
  33. value-format="yyyy-MM-dd"
  34. type="date">
  35. </el-date-picker>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button @click="queryData()">查询</el-button>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button @click="batchApprove()">批量审批</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-table
  45. :data="dataList"
  46. border
  47. v-loading="dataListLoading"
  48. @selection-change="selectionChangeHandle"
  49. style="width: 100%;">
  50. <el-table-column
  51. type="selection"
  52. width="55">
  53. </el-table-column>
  54. <el-table-column
  55. label="序号"
  56. type="index"
  57. width="50"
  58. align="center">
  59. </el-table-column>
  60. <el-table-column
  61. prop="businessTypeName"
  62. header-align="center"
  63. align="center"
  64. min-width="180"
  65. label="流程类别">
  66. </el-table-column>
  67. <el-table-column
  68. prop="createTime"
  69. header-align="center"
  70. align="center"
  71. min-width="160"
  72. :show-overflow-tooltip="true"
  73. label="申请时间">
  74. </el-table-column>
  75. <el-table-column
  76. prop="updateTime"
  77. header-align="center"
  78. align="center"
  79. min-width="160"
  80. :show-overflow-tooltip="true"
  81. label="更新时间">
  82. </el-table-column>
  83. <el-table-column
  84. prop="state"
  85. header-align="center"
  86. align="center"
  87. min-width="100"
  88. label="状态">
  89. <template slot-scope="scope">
  90. <span>{{(optionsState.find(t=>t.code === scope.row.state.toString())).value}}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column
  94. prop="creatorName"
  95. header-align="center"
  96. align="center"
  97. min-width="120"
  98. label="申请人">
  99. </el-table-column>
  100. <el-table-column
  101. prop="orgName"
  102. header-align="center"
  103. align="center"
  104. min-width="140"
  105. :show-tooltip-when-overflow="true"
  106. label="申请部门">
  107. </el-table-column>
  108. <el-table-column
  109. fixed="right"
  110. header-align="center"
  111. align="center"
  112. width="80"
  113. label="操作">
  114. <template slot-scope="scope">
  115. <el-button v-if="isAuth('business:approval:approval') && Number(scope.row.state) !== 3 && checkUser(scope.row)" type="text" size="small" @click="addOrUpdateHandle(scope.row)">处理</el-button>
  116. <el-button v-if="isAuth('business:approval:info') && (Number(scope.row.state) === 3 || !checkUser(scope.row))" type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <el-pagination
  121. @size-change="sizeChangeHandle"
  122. @current-change="currentChangeHandle"
  123. :current-page="pageIndex"
  124. :page-sizes="[10, 20, 50, 100]"
  125. :page-size="pageSize"
  126. :total="totalPage"
  127. layout="total, sizes, prev, pager, next, jumper">
  128. </el-pagination>
  129. </template>
  130. <!-- 弹窗, 新增 / 修改 -->
  131. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getApprovalList" @onChose="onChose"/>
  132. <el-dialog :visible.sync="approveDialogVisible">
  133. <approve-component-batch ref="approve" @approveFinished="approveChose" />
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import AddOrUpdate from './approve-add-or-update'
  139. import { getApprovalList } from '@/api/msg'
  140. import { readNotices } from '@/utils/msg'
  141. import { getCusList } from '@/api/cus'
  142. import { checkStr } from '@/api/util'
  143. import ApproveComponentBatch from '../common/approve-component-batch'
  144. export default {
  145. name: 'order',
  146. components: {
  147. // Detail,
  148. AddOrUpdate,
  149. ApproveComponentBatch
  150. },
  151. created () {
  152. this.optionsState = this.$store.state.common.approveStates
  153. this.queryData()
  154. },
  155. computed: {
  156. // 监听消息ID
  157. listenNotice () {
  158. return this.$route.params.notice
  159. }
  160. },
  161. watch: {
  162. listenNotice: function (notice) {
  163. // console.log('notice = ' + JSON.stringify(notice))
  164. if (!notice) return
  165. this.dataForm.noticeId = notice.noticeId
  166. this.dataForm.businessId = notice.businessId
  167. this.queryData()
  168. }
  169. },
  170. data () {
  171. return {
  172. approveDialogVisible: false,
  173. addOrUpdateVisible: false,
  174. dataForm: {},
  175. dataList: [],
  176. pageIndex: 1,
  177. pageSize: 10,
  178. totalPage: 0,
  179. dataListLoading: false,
  180. dataListSelections: [],
  181. optionsState: [],
  182. optionsType: [
  183. {
  184. code: null, value: '全部'
  185. },
  186. {
  187. code: 'warehouse_flow_in', value: '入库申请'
  188. },
  189. {
  190. code: 'warehouse_flow_out', value: '出库申请'
  191. },
  192. {
  193. code: 'contract_review', value: '合同评审'
  194. },
  195. {
  196. code: 'sale_order_flow', value: '任务单评审'
  197. },
  198. {
  199. code: 'sale_purchase_flow', value: '采购申请'
  200. },
  201. {
  202. code: 'wh_template_record_flow', value: '模板出库'
  203. },
  204. {
  205. code: 'pro_technology_flow', value: '工艺评审'
  206. },
  207. {
  208. code: 'pro_product_flow', value: '物料评审'
  209. },
  210. {
  211. code: 'wh_inventory_record_flow', value: '盘点评审'
  212. },
  213. {
  214. code: 'supplier_review_flow', value: '供应商评审'
  215. },
  216. {
  217. code: 'submit_expense_flow', value: '报销审批'
  218. },
  219. {
  220. code: 'pur_commission_flow', value: '委外审批'
  221. },
  222. {
  223. code: 'work_damage_flow', value: '报损审批'
  224. },
  225. {
  226. code: 'cus_communicate_flow', value: '沟通审批'
  227. },
  228. {
  229. code: 'project_estimate', value: '项目评估'
  230. },
  231. {
  232. code: 'first_identify_flow', value: '首件鉴定'
  233. },
  234. {
  235. code: 'nonconforming_hear_flow', value: '不合格品审理'
  236. }
  237. ],
  238. optionsCustomer: []
  239. }
  240. },
  241. methods: {
  242. onChose () {
  243. this.addOrUpdateVisible = false
  244. },
  245. // 查询
  246. queryData () {
  247. this.pageIndex = 1
  248. this.getApprovalList()
  249. },
  250. // 获取数据列表
  251. getApprovalList () {
  252. this.dataList = []
  253. this.dataListLoading = true
  254. let params = {
  255. 'current': this.pageIndex,
  256. 'size': this.pageSize,
  257. 'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
  258. 'state': this.dataForm.state ? this.dataForm.state : null,
  259. 'businessType': this.dataForm.businessType ? this.dataForm.businessType : null,
  260. 'businessId': this.dataForm.businessId ? this.dataForm.businessId : null
  261. }
  262. getApprovalList(params).then(({data}) => {
  263. if (data && data.code === '200') {
  264. this.dataList = data.data.records
  265. this.totalPage = Number(data.data.total)
  266. } else {
  267. this.dataList = []
  268. this.totalPage = 0
  269. }
  270. this.dataListLoading = false
  271. })
  272. },
  273. // 每页数
  274. sizeChangeHandle (val) {
  275. this.pageSize = val
  276. this.pageIndex = 1
  277. this.getApprovalList()
  278. },
  279. // 当前页
  280. currentChangeHandle (val) {
  281. this.pageIndex = val
  282. this.getApprovalList()
  283. },
  284. // 多选
  285. selectionChangeHandle (val) {
  286. this.dataListSelections = val
  287. },
  288. // 远程方法:获取客户列表
  289. async remoteCustomer (query) {
  290. if (!query) {
  291. query = ''
  292. }
  293. await getCusList({'customerName': query}).then(({data}) => {
  294. if (data && data.code === '200') {
  295. this.optionsCustomer = []
  296. data.data.records.forEach((item) => {
  297. this.optionsCustomer.push({
  298. code: item.customerId,
  299. value: item.customerName
  300. })
  301. })
  302. }
  303. })
  304. },
  305. checkUser (row) {
  306. let currentUser = this.$store.state.user.id
  307. return checkStr(currentUser, row.currentApprover)
  308. },
  309. // 新增 / 修改
  310. addOrUpdateHandle (row) {
  311. this.addOrUpdateVisible = true
  312. // 已查看
  313. if (row.noticeIds) {
  314. readNotices(this, row.noticeIds)
  315. }
  316. this.$nextTick(() => {
  317. this.$refs.addOrUpdate.init(row.businessType, row.businessId)
  318. })
  319. },
  320. // 详情
  321. detailHandle (row) {
  322. this.addOrUpdateVisible = true
  323. this.$nextTick(() => {
  324. this.$refs.addOrUpdate.init(row.businessType, row.businessId, true)
  325. })
  326. // 已查看
  327. if (row.noticeIds) {
  328. readNotices(this, row.noticeIds)
  329. }
  330. },
  331. batchApprove () {
  332. console.log(this.dataListSelections)
  333. if (this.dataListSelections && this.dataListSelections.length > 0) {
  334. this.approveDialogVisible = true
  335. let businessIds = this.dataListSelections.map(item => item.businessId)
  336. this.$nextTick(() => {
  337. this.$refs.approve.init(this.dataListSelections[0].businessType, businessIds)
  338. })
  339. } else {
  340. }
  341. },
  342. approveChose () {
  343. this.approveDialogVisible = false
  344. this.queryData()
  345. }
  346. }
  347. }
  348. </script>
  349. <style scoped>
  350. </style>