综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

approval.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="申请人" prop="applier">
  5. <el-select v-model="queryParams.applier" filterable clearable @change="handleQuery">
  6. <el-option v-for="item in $store.state.user.userList" :key="item.userId" :label="item.nickName"
  7. :value="item.userId">
  8. </el-option>
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item label="申请部门" prop="useDept">
  12. <el-select v-model="queryParams.useDept" filterable clearable @change="handleQuery">
  13. <el-option v-for="item in $store.state.user.deptList" :key="item.deptId" :label="item.deptName"
  14. :value="item.deptId">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="项目编号" prop="projectId">
  19. <el-select v-model="queryParams.projectId" clearable filterable remote reserve-keyword placeholder="请输入项目编号"
  20. :remote-method="remoteMethod" :loading="loading" style="width: 400px;">
  21. <el-option v-for="project in projectList" :key="project.projectId"
  22. :label="project.projectNumber + '-' + project.projectName" :value="project.projectId">
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="申请类型" prop="carUsage">
  27. <el-select v-model="queryParams.carUsage" clearable @change="handleQuery">
  28. <el-option label="项目用车" value="0"></el-option>
  29. <el-option label="非项目用车" value="1"></el-option>
  30. <el-option label="工会用车" value="2"></el-option>
  31. <el-option label="党委用车" value="3"></el-option>
  32. <el-option label="团委用车" value="4"></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. </el-form-item>
  38. </el-form>
  39. <el-row :gutter="10" class="mb8">
  40. <el-col :span="1.5">
  41. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  42. v-hasPermi="['car:record:export']">导出</el-button>
  43. </el-col>
  44. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  45. </el-row>
  46. <el-table v-loading="loading" :data="carApprovalList" @selection-change="handleSelectionChange">
  47. <el-table-column type="index" label="序号" width="55" align="center" />
  48. <!-- <el-table-column label="用车申请id" align="center" prop="carApplyId" /> -->
  49. <el-table-column label="申请类型" align="center" prop="carUsage">
  50. <template slot-scope="scope">
  51. <el-tag :type="setTypeCarUsage(scope.row.carUsage)">
  52. {{ setCarUsage(scope.row.carUsage) }}
  53. </el-tag>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="申请人" align="center" prop="applier">
  57. <template slot-scope="scope">
  58. {{ getUserName(scope.row.applier) }}
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="申请部门" align="center" prop="useDept">
  62. <template slot-scope="scope">
  63. {{ getDeptName(scope.row.useDept) }}
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="项目编号" align="center" prop="project.projectNumber" />
  67. <el-table-column label="项目名称" align="center" prop="project.projectName" width="200px" />
  68. <el-table-column label="用车事由" align="center" prop="applyReason" />
  69. <el-table-column label="乘车人数" align="center" prop="passengers" />
  70. <el-table-column label="开始日期" align="center" prop="beginDate">
  71. <template slot-scope="scope">
  72. <span>{{ parseTime(scope.row.beginDate, '{y}-{m}-{d}') }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="结束日期" align="center" prop="endDate">
  76. <template slot-scope="scope">
  77. <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="天数" align="center" prop="days" />
  81. <!-- <el-table-column label="部门审批人" align="center" prop="deptUser.nickName" /> -->
  82. <el-table-column label="申请日期" align="center" prop="applyDate">
  83. <template slot-scope="scope">
  84. <span>{{ parseTime(scope.row.applyDate, '{y}-{m}-{d}') }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  88. <template slot-scope="scope">
  89. <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  94. @pagination="getList" />
  95. <!-- 添加或修改cmc用车审批对话框 -->
  96. <el-dialog :title="title" :visible.sync="open" width="65%" append-to-body>
  97. <car-form :taskForm="taskForm" :taskName="''" :flowDisabled="false"></car-form>
  98. </el-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import { listCarApproval, getCarApproval, delCarApproval, addCarApproval, updateCarApproval } from "@/api/oa/car/carApproval";
  103. import { listProject } from '@/api/oa/project/project';
  104. import carForm from '../../flowable/form/oa/carForm.vue';
  105. import { mapGetters } from 'vuex'
  106. export default {
  107. components: { carForm },
  108. name: "CarApproval",
  109. computed: {
  110. ...mapGetters(['roles', 'deptId']),
  111. },
  112. data() {
  113. return {
  114. // 遮罩层
  115. loading: true,
  116. // 选中数组
  117. ids: [],
  118. // 非单个禁用
  119. single: true,
  120. // 非多个禁用
  121. multiple: true,
  122. // 显示搜索条件
  123. showSearch: true,
  124. // 总条数
  125. total: 0,
  126. // cmc用车审批表格数据
  127. carApprovalList: [],
  128. // 弹出层标题
  129. title: "",
  130. // 是否显示弹出层
  131. open: false,
  132. // 查询参数
  133. queryParams: {
  134. pageNum: 1,
  135. pageSize: 10,
  136. applier: null,
  137. useDept: null,
  138. cars: null,
  139. drivers: null,
  140. projectId: null,
  141. carUsage: null,
  142. applyReason: null,
  143. passengers: null,
  144. beginDate: null,
  145. endDate: null,
  146. days: null,
  147. deptUserId: null,
  148. deptComment: null,
  149. deptTime: null,
  150. managerUserId: null,
  151. managerComment: null,
  152. managerTime: null,
  153. unionUserId: null,
  154. unionComment: null,
  155. unionTime: null,
  156. gmUserId: null,
  157. gmComment: null,
  158. gmTime: null,
  159. dispatcher: null,
  160. dispatchComment: null,
  161. dispatchTime: null,
  162. estimateCost: null,
  163. applyDate: null
  164. },
  165. // 表单参数
  166. form: {},
  167. // 表单校验
  168. rules: {
  169. },
  170. projectList: [],
  171. taskForm: {
  172. formId: ''
  173. }
  174. };
  175. },
  176. created() {
  177. this.queryParams.carUsage = '0'
  178. this.getList();
  179. },
  180. methods: {
  181. /** 查询cmc用车审批列表 */
  182. getList() {
  183. this.loading = true;
  184. if (this.roles.some(element => element === "dept")) {
  185. if (this.queryParams.carUsage == '0') {
  186. this.queryParams.undertakingDept = this.deptId;
  187. this.queryParams.useDept = null;
  188. }
  189. else {
  190. this.queryParams.useDept = this.deptId;
  191. this.queryParams.undertakingDept = null;
  192. }
  193. }
  194. if (this.roles.some(e => e === 'leader')) {
  195. this.queryParams.useDept = null;
  196. this.queryParams.undertakingDept = null;
  197. }
  198. listCarApproval(this.queryParams).then(response => {
  199. this.carApprovalList = response.rows;
  200. this.total = response.total;
  201. this.loading = false;
  202. });
  203. },
  204. remoteMethod(val) {
  205. listProject({
  206. pageNum: 1,
  207. pageSize: 20,
  208. projectNumber: val
  209. }).then(res => {
  210. this.projectList = res.rows;
  211. })
  212. },
  213. // 取消按钮
  214. cancel() {
  215. this.open = false;
  216. this.reset();
  217. },
  218. // 表单重置
  219. reset() {
  220. this.form = {
  221. carApplyId: null,
  222. applier: null,
  223. useDept: null,
  224. cars: null,
  225. drivers: null,
  226. projectId: null,
  227. carUsage: null,
  228. applyReason: null,
  229. passengers: null,
  230. beginDate: null,
  231. endDate: null,
  232. days: null,
  233. deptUserId: null,
  234. deptComment: null,
  235. deptTime: null,
  236. managerUserId: null,
  237. managerComment: null,
  238. managerTime: null,
  239. unionUserId: null,
  240. unionComment: null,
  241. unionTime: null,
  242. gmUserId: null,
  243. gmComment: null,
  244. gmTime: null,
  245. dispatcher: null,
  246. dispatchComment: null,
  247. dispatchTime: null,
  248. estimateCost: null,
  249. applyDate: null
  250. };
  251. this.resetForm("form");
  252. },
  253. /** 搜索按钮操作 */
  254. handleQuery() {
  255. this.queryParams.pageNum = 1;
  256. this.getList();
  257. },
  258. /** 重置按钮操作 */
  259. resetQuery() {
  260. this.resetForm("queryForm");
  261. this.handleQuery();
  262. },
  263. // 多选框选中数据
  264. handleSelectionChange(selection) {
  265. this.ids = selection.map(item => item.carApplyId)
  266. this.single = selection.length !== 1
  267. this.multiple = !selection.length
  268. },
  269. /** 新增按钮操作 */
  270. handleAdd() {
  271. this.reset();
  272. this.open = true;
  273. this.title = "添加cmc用车审批";
  274. },
  275. handleView(row) {
  276. this.open = true;
  277. this.taskForm.formId = row.carApplyId;
  278. },
  279. /** 修改按钮操作 */
  280. handleUpdate(row) {
  281. this.reset();
  282. const carApplyId = row.carApplyId || this.ids
  283. getCarApproval(carApplyId).then(response => {
  284. this.form = response.data;
  285. this.open = true;
  286. this.title = "修改cmc用车审批";
  287. });
  288. },
  289. /** 提交按钮 */
  290. submitForm() {
  291. this.$refs["form"].validate(valid => {
  292. if (valid) {
  293. if (this.form.carApplyId != null) {
  294. updateCarApproval(this.form).then(response => {
  295. this.$modal.msgSuccess("修改成功");
  296. this.open = false;
  297. this.getList();
  298. });
  299. } else {
  300. addCarApproval(this.form).then(response => {
  301. this.$modal.msgSuccess("新增成功");
  302. this.open = false;
  303. this.getList();
  304. });
  305. }
  306. }
  307. });
  308. },
  309. /** 删除按钮操作 */
  310. handleDelete(row) {
  311. const carApplyIds = row.carApplyId || this.ids;
  312. this.$modal.confirm('是否确认删除cmc用车审批编号为"' + carApplyIds + '"的数据项?').then(function () {
  313. return delCarApproval(carApplyIds);
  314. }).then(() => {
  315. this.getList();
  316. this.$modal.msgSuccess("删除成功");
  317. }).catch(() => { });
  318. },
  319. /** 导出按钮操作 */
  320. handleExport() {
  321. this.download('oa/carApproval/export', {
  322. ...this.queryParams
  323. }, `carApproval_${new Date().getTime()}.xlsx`)
  324. },
  325. setCarUsage(val) {
  326. if (val == '0') {
  327. return '项目用车'
  328. } else if (val == '1') {
  329. return '非项目用车'
  330. } else if (val == '2') {
  331. return '工会用车'
  332. } else if (val == '3') {
  333. return '党委用车'
  334. } else if (val == '4') {
  335. return '团委用车'
  336. }
  337. },
  338. setTypeCarUsage(val) {
  339. if (val == '0') {
  340. return 'success'
  341. } else if (val == '1') {
  342. return 'warning'
  343. } else {
  344. return ''
  345. }
  346. }
  347. }
  348. };
  349. </script>