index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <el-card class="tjm_card_style_custom">
  3. <div class="tjm_card_title">查询表格</div>
  4. <div class="tjm_card_select">
  5. <el-form class="tjm_card_select_left" :model="params" inline label-width="80px" label-position="left">
  6. <!-- <el-form-item label="所属部门">
  7. <el-tree-select v-model="deptQuery.modelValue" :data="deptQuery.data" :props="deptQuery.props" check-strictly filterable clearable placeholder="请选择所属部门" @node-click="nodeClick"></el-tree-select>
  8. </el-form-item> -->
  9. <el-form-item label="政策编号">
  10. <el-input v-model="params.businessNo" clearable placeholder="请输入政策编号"></el-input>
  11. </el-form-item>
  12. <el-form-item label="政策名称">
  13. <el-input v-model="params.name" clearable placeholder="请输入政策名称"></el-input>
  14. </el-form-item>
  15. <el-form-item label="政策等级">
  16. <el-select v-model="params.zcLevel" clearable placeholder="请选择政策等级">
  17. <el-option v-for="item in levelDic" :key="item" :label="item" :value="item"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="政策类别">
  21. <el-select v-model="params.zcType" clearable placeholder="请选择政策类别">
  22. <el-option v-for="item in typeDic" :key="item" :label="item" :value="item"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="状态">
  26. <el-select v-model="params.status" clearable placeholder="请选择状态">
  27. <el-option v-for="(label, key) in statusDic" :key="key" :label="label" :value="key"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="是否入库">
  31. <el-select v-model="params.isInWh" clearable placeholder="请选择入库状态">
  32. <el-option v-for="(label, key) in whetherDic" :key="key" :label="label" :value="key"></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="入库类别">
  36. <el-select v-model="params.inWhType" clearable placeholder="请选择入库类别">
  37. <el-option v-for="item in storageTypeDic" :key="item" :label="item" :value="item"></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="填报日期">
  41. <el-date-picker v-model="createTime" type="daterange" value-format="YYYY-MM-DD" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="primary" icon="search" @click="reloadTable">搜索</el-button>
  45. <el-button icon="refresh-right" @click="reset">重置</el-button>
  46. </el-form-item>
  47. </el-form>
  48. </div>
  49. <el-divider></el-divider>
  50. <div class="tjm_card_tools">
  51. <div class="tjm_card_tools_left">
  52. <el-button type="primary" icon="plus" @click="table_add">新增</el-button>
  53. </div>
  54. <div class="tjm_card_tools_right flex-row">
  55. <table-import url="policyShare" @importSuc="reloadTable"></table-import>
  56. <el-button class="export-btn" icon="download" @click="table_export">导出</el-button>
  57. <el-button icon="download" @click="download_temp">导入模版下载</el-button>
  58. </div>
  59. </div>
  60. <div class="tjm_card_table">
  61. <el-table v-loading="loading" row-key="id" header-cell-class-name="tjm_card_table_header" height="400" :data="tableData" border @row-click="(row, column) => !column.fixed && table_detail(row)">
  62. <el-table-column type="index" label="序号" width="55"></el-table-column>
  63. <template v-for="(item, index) in columns" :key="index">
  64. <el-table-column :label="item.label" :prop="item.props" :width="item.width || 180" show-overflow-tooltip>
  65. <template #default="scope">{{ columnFormat(scope.row, item.props) }}</template>
  66. </el-table-column>
  67. </template>
  68. <el-table-column label="操作" fixed="right" width="280">
  69. <template #default="scope">
  70. <template v-if="scope.row.status == 'active' || scope.row.status == 'inactive'">
  71. <template v-if="scope.row.status == 'active'">
  72. <el-button type="primary" link icon="edit" @click.stop="table_edit(scope.row)">修改</el-button>
  73. <el-button type="primary" link icon="upload" @click.stop="table_edit(scope.row)">上报</el-button>
  74. </template>
  75. <template v-if="scope.row.status == 'inactive'">
  76. <el-button type="primary" link icon="tickets" @click.stop="table_edit(scope.row)">重新上报</el-button>
  77. <el-button v-if="scope.row.processTaskId && scope.row.processInstanceId" type="primary" link @click.stop="table_process(scope.row)">
  78. <template #icon><tjm-icon-uis-process /></template>
  79. 审批流程
  80. </el-button>
  81. </template>
  82. <el-button type="primary" link icon="delete" @click.stop="table_del(scope.row)">删除</el-button>
  83. </template>
  84. <template v-if="scope.row.status == 'approve' || scope.row.status == 'done'">
  85. <el-button type="primary" link icon="tickets" @click.stop="table_detail(scope.row)">详情</el-button>
  86. <el-button v-if="scope.row.processTaskId && scope.row.processInstanceId" type="primary" link @click.stop="table_process(scope.row)">
  87. <template #icon><tjm-icon-uis-process /></template>
  88. 审批流程
  89. </el-button>
  90. </template>
  91. <el-button v-if="scope.row.status == 'approve' && scope.row.isWithdraw == 1" type="primary" link icon="refresh-right" @click.stop="table_withdraw(scope.row)">撤回</el-button>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. </div>
  96. <div class="tjm_card_pagination">
  97. <yh-pagination v-model:pageNo="params.page" v-model:pageSize="params.size" :total="total" @paginationChange="reloadTable"></yh-pagination>
  98. </div>
  99. </el-card>
  100. <policy-dialog v-if="dialog.update" ref="policyDialog" @success="reloadTable" @closed="closed"></policy-dialog>
  101. <policy-detail v-if="dialog.detail" ref="policyDetail" @closed="dialog.detail = false"></policy-detail>
  102. <policy-process-dialog v-if="dialog.process" ref="processDialog" @success="reloadTable" @closed="dialog.process = false"></policy-process-dialog>
  103. <yh-workflow v-if="dialog.workflow" ref="yhWorkflow" @closed="dialog.workflow = false"></yh-workflow>
  104. </template>
  105. <script>
  106. import Folder from "@/api/folder";
  107. import Temp from "@/api/system/template";
  108. import { getMainList } from "@/api/system/depart";
  109. import API from "@/api/policy/share";
  110. import { useUserStore } from "@/store/user";
  111. import { exportExcel } from "@/utils/exportExcel";
  112. import { columns, levelDic, typeDic, storageTypeDic, whetherDic, statusDic } from "./main";
  113. import tableImport from "@/components/Upload/tableImport.vue";
  114. import yhPagination from "@/components/Pagination/index.vue";
  115. import policyDetail from "@/views/manage/policyShare/dialog.vue";
  116. import policyDialog from "./dialog.vue";
  117. import policyProcessDialog from "@/views/toDo/share.vue";
  118. import yhWorkflow from "@/components/Workflow/index.vue";
  119. export default {
  120. components: {
  121. tableImport,
  122. yhPagination,
  123. yhWorkflow,
  124. policyDetail,
  125. policyDialog,
  126. policyProcessDialog
  127. },
  128. data() {
  129. return {
  130. columns, levelDic, typeDic, storageTypeDic, whetherDic, statusDic,
  131. deptQuery: {
  132. modelValue: null,
  133. data: [],
  134. props: {
  135. label: "name",
  136. value: "id"
  137. },
  138. paramsFormat: {
  139. 0: "companyId",
  140. 1: "deptId"
  141. }
  142. },
  143. loading: false,
  144. createTime: [],
  145. params: {
  146. page: 1,
  147. size: 10,
  148. createId: useUserStore().userInfo.id,
  149. userDeptId: useUserStore().userInfo.deptId
  150. },
  151. total: 0,
  152. tableData: [],
  153. dialog: {
  154. update: false,
  155. detail: false,
  156. process: false,
  157. workflow: false
  158. }
  159. }
  160. },
  161. mounted() {
  162. this.getDeptTree();
  163. this.reloadTable();
  164. },
  165. methods: {
  166. columnFormat(row, props) {
  167. if (props == "createTime") return row[props].split(" ")[0];
  168. if (props == "status") return statusDic[row[props]] || "";
  169. if (props == "isInWh") return whetherDic[row[props]] || "";
  170. return row[props];
  171. },
  172. getDeptTree() {
  173. getMainList().then(res => {
  174. if (res.code === 200) this.deptQuery.data = res.data;
  175. else ElMessage.error(res.msg);
  176. });
  177. },
  178. reloadTable(mode = "add") {
  179. if (mode == "add") this.params.page = 1;
  180. this.params.beginCreateTime = this.createTime && this.createTime.length && this.createTime[0] + " 00:00:00" || null;
  181. this.params.endCreateTime = this.createTime && this.createTime.length && this.createTime[1] + " 23:59:59" || null;
  182. this.loading = true;
  183. API.get(this.params).then(res => {
  184. this.loading = false;
  185. if (res.code === 200) {
  186. this.tableData = res.data.records;
  187. this.total = res.data.total;
  188. } else ElMessage.error(res.msg);
  189. }).catch(() => this.loading = false);
  190. },
  191. reset() {
  192. this.createTime = [];
  193. this.params = {
  194. page: 1,
  195. size: 10,
  196. createId: useUserStore().userInfo.id,
  197. userDeptId: useUserStore().userInfo.deptId
  198. }
  199. this.reloadTable();
  200. },
  201. nodeClick({ deptType, id }) {
  202. for (const key in this.deptQuery.paramsFormat) {
  203. this.params[this.deptQuery.paramsFormat[key]] = null;
  204. }
  205. this.params[this.deptQuery.paramsFormat[deptType]] = id;
  206. },
  207. table_export() {
  208. const header = columns.map(c => c.label);
  209. const data = this.tableData.map(v => columns.map(c => c.props).map(j => this.columnFormat(v, j)));
  210. exportExcel(header, data, [], `${this.$route.name}.xlsx`);
  211. },
  212. download_temp() {
  213. Temp.get({ refType: "policy_share" }).then(res => {
  214. if (res.code === 200) {
  215. if (!res.data.records[0]) ElMessage.warning("暂无模版,请联系管理员");
  216. else {
  217. const { templateName, templateUrl } = res.data.records[0];
  218. Folder.download(templateUrl).then(res => {
  219. const a = document.createElement("a");
  220. const blob = new Blob([res.data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
  221. a.download = templateName;
  222. a.href = URL.createObjectURL(blob);
  223. a.click();
  224. });
  225. }
  226. }else ElMessage.error(res.msg);
  227. });
  228. },
  229. table_add() {
  230. this.dialog.update = true;
  231. this.$nextTick(() => this.$refs.policyDialog.open());
  232. },
  233. table_edit(row) {
  234. if (row.status == "inactive") {
  235. this.dialog.process = true;
  236. this.$nextTick(() => this.$refs.processDialog.open("resubmit").setData(row.id));
  237. }
  238. if (row.status == "active") {
  239. this.dialog.update = true;
  240. this.$nextTick(() => this.$refs.policyDialog.open("edit").setData(row.id));
  241. }
  242. },
  243. table_detail(row) {
  244. this.dialog.detail = true;
  245. this.$nextTick(() => this.$refs.policyDetail.open("detail").setData(row.id));
  246. },
  247. table_del(row) {
  248. ElMessageBox.confirm("是否确认删除?", "删除警告", {
  249. type: "warning",
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消"
  252. }).then(() => {
  253. API.del({ ids: row.id }).then(res => {
  254. if (res.code == 200) {
  255. ElMessage.success("操作成功");
  256. this.reloadTable();
  257. } else ElMessage.error(res.msg);
  258. });
  259. });
  260. },
  261. table_withdraw(row) {
  262. ElMessageBox.confirm("是否确认撤回?", "提示", {
  263. type: "warning",
  264. confirmButtonText: "确定",
  265. cancelButtonText: "取消"
  266. }).then(() => {
  267. API.withdraw(row).then(res => {
  268. if (res.code === 200) {
  269. ElMessage.success("操作成功");
  270. this.reloadTable();
  271. } else ElMessage.error(res.msg);
  272. });
  273. });
  274. },
  275. closed(e) {
  276. e && this.reloadTable();
  277. this.dialog.update = false;
  278. },
  279. table_process(row) {
  280. this.dialog.workflow = true;
  281. this.$nextTick(() => this.$refs.yhWorkflow.getDetail(row));
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .export-btn {
  288. margin-left: 12px;
  289. }
  290. </style>