index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <div class="app-container">
  3. <!--机构数据-->
  4. <!-- <el-col :span="4" :xs="24" v-if="false">
  5. <org-tree
  6. v-model="queryParams.orgId"
  7. @defaultKey="getDefaultKey"
  8. @checkChange="checkChange"
  9. @click="clickTreeNode"
  10. wholeTree
  11. ></org-tree>
  12. </el-col> -->
  13. <!--用户数据-->
  14. <div class="main-right-box">
  15. <!-- 搜索条件 -->
  16. <div class="main-search-box">
  17. <el-form
  18. :model="queryParams"
  19. ref="queryForm"
  20. size="small"
  21. :inline="true"
  22. v-show="showSearch"
  23. >
  24. <el-row :gutter="50">
  25. <el-col :span="6" :xs="14">
  26. <el-form-item prop="type" label="签署类型">
  27. <el-select
  28. prop="type"
  29. label="签署类型"
  30. v-model="queryParams.type"
  31. placeholder="请选择签署类型"
  32. clearable
  33. >
  34. <el-option
  35. v-for="dict in dict.type.safety_book_type"
  36. :key="dict.value"
  37. :label="dict.label"
  38. :value="dict.value"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="6" :xs="24">
  44. <el-form-item label="所属年度" prop="year">
  45. <el-date-picker
  46. v-model="queryParams.year"
  47. :clearable="timeClearable"
  48. type="year"
  49. placeholder="选择时间"
  50. value-format="yyyy"
  51. >
  52. </el-date-picker>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6" :xs="24">
  56. <el-form-item label="签署机构" prop="orgId" class="formTreeItem">
  57. <tree-select
  58. v-model="queryParams.orgId"
  59. :options="deptOptions"
  60. :show-count="true"
  61. :normalizer="tenantIdnormalizer"
  62. :props="{ checkStrictly: true, label: 'name' }"
  63. placeholder="请选择签署机构"
  64. clearValueText="清除"
  65. :noChildrenText="''"
  66. noOptionsText="没有数据"
  67. noResultsText="没有搜索结果"
  68. />
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. </el-form>
  73. <el-row :gutter="10" class="mb8">
  74. <el-col :span="1.5">
  75. <el-button
  76. type="primary"
  77. icon="el-icon-search"
  78. size="mini"
  79. @click="getList"
  80. >搜索</el-button
  81. >
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="primary"
  86. icon="el-icon-refresh"
  87. size="mini"
  88. @click="resetQuery"
  89. >重置</el-button
  90. >
  91. </el-col>
  92. <el-col :span="1.5">
  93. <el-button
  94. type="primary"
  95. icon="el-icon-plus"
  96. size="mini"
  97. @click="handleAdd(null)"
  98. v-hasPermi="['core:book:add']"
  99. >新增
  100. </el-button>
  101. </el-col>
  102. <right-toolbar
  103. :showSearch.sync="showSearch"
  104. @queryTable="getList"
  105. ></right-toolbar>
  106. </el-row>
  107. </div>
  108. <!-- 表格数据 -->
  109. <el-table
  110. border
  111. height="700"
  112. size="small"
  113. v-loading="loading"
  114. :data="dataList"
  115. >
  116. <el-table-column label="序号" type="index" align="center" width="60" />
  117. <el-table-column
  118. label="签署机构"
  119. align="left"
  120. width="400"
  121. prop="orgName"
  122. />
  123. <el-table-column label="签署类型" align="left" width="300" prop="type">
  124. <template slot-scope="r"
  125. >{{ getLabel(dict.type.safety_book_type, `${r.row.type}`) }}
  126. </template>
  127. </el-table-column>
  128. <el-table-column
  129. label="所属年度"
  130. align="center"
  131. width="200"
  132. prop="year"
  133. />
  134. <el-table-column
  135. v-if="false"
  136. label="签署人"
  137. align="center"
  138. prop="userName"
  139. >
  140. </el-table-column>
  141. <el-table-column label="签署时间" align="center" prop="createTime" >
  142. <template slot-scope="r">
  143. {{ r.row.createTime ? dayjs(r.row.createTime).format("YYYY年-MM月-DD日") : "" }}
  144. </template>
  145. </el-table-column>
  146. <el-table-column
  147. label="操作"
  148. width="250"
  149. fixed="right"
  150. align="center"
  151. class-name="small-padding fixed-width"
  152. >
  153. <template slot-scope="scope">
  154. <el-button
  155. size="mini"
  156. type="text"
  157. icon="el-icon-info"
  158. @click="handleInfo(scope.row.id)"
  159. v-hasPermi="['core:book:query']"
  160. >详情
  161. </el-button>
  162. <el-button
  163. size="mini"
  164. type="text"
  165. icon="el-icon-edit-outline"
  166. @click="handleAdd(scope.row.id)"
  167. v-hasPermi="['core:book:add']"
  168. >编辑
  169. </el-button>
  170. <el-button
  171. size="mini"
  172. type="text"
  173. icon="el-icon-delete"
  174. @click="handleDelete(scope.row)"
  175. v-hasPermi="['core:book:remove']"
  176. >删除
  177. </el-button>
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. <pagination
  182. v-show="total > 0"
  183. :total="total"
  184. :page.sync="queryParams.pageNum"
  185. :limit.sync="queryParams.pageSize"
  186. @pagination="getList"
  187. />
  188. </div>
  189. <dialog-edit ref="editDialog" @success="getList()"></dialog-edit>
  190. <DialogDes ref="DialogDes"></DialogDes>
  191. </div>
  192. </template>
  193. <script>
  194. import {
  195. listSafetyBook,
  196. getSafetyBook,
  197. editOrAdd,
  198. delSafetyBook,
  199. } from "@/api/safetyBook/index";
  200. import { getLabel } from "@/views/commonOption";
  201. import DialogEdit from "./dialog.edit";
  202. import DialogDes from "./dialog.des";
  203. import { deptTreeSelect } from "@/api/system/public";
  204. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  205. import OrgTree from "@/components/orgTree/index.vue";
  206. import kOrgTree from "@/components/k-orgTree/index.vue";
  207. import KFileUpload from "@/components/K-FileUpload/index.vue";
  208. import tableList from "@/mixins/tableList";
  209. import orgTree from "@/components/orgTree";
  210. import dayjs from "dayjs";
  211. export default {
  212. dicts: ["safety_book_type"],
  213. name: "safetyBook",
  214. components: {
  215. OrgTree,
  216. kOrgTree,
  217. KFileUpload,
  218. DialogEdit,
  219. orgTree,
  220. DialogDes,
  221. },
  222. mixins: [tableList],
  223. data() {
  224. return {
  225. // 遮罩层
  226. loading: true,
  227. // 选中数组
  228. ids: [],
  229. // 非单个停用
  230. single: true,
  231. // 非多个停用
  232. multiple: true,
  233. // 显示搜索条件
  234. showSearch: true,
  235. // 总条数
  236. total: 0,
  237. // 安全责任书表格数据
  238. dataList: [],
  239. // 弹出层标题
  240. title: "",
  241. // 是否显示弹出层
  242. open: false,
  243. // 机构树选项
  244. deptOptions: [],
  245. // 机构名称
  246. deptName: undefined,
  247. //是否关联下级
  248. checked: false,
  249. timeClearable: true,
  250. defaultProps: {
  251. children: "children",
  252. label: "name",
  253. },
  254. formFileListDefualtValue: [],
  255. // 查询参数
  256. queryParams: {
  257. checkSub: true,
  258. pageNum: 1,
  259. pageSize: 10,
  260. orgId: null,
  261. year: null,
  262. searchOrgId: null,
  263. type: null,
  264. },
  265. // 表单参数
  266. form: {},
  267. //默认选中节点
  268. defaultKeys: [],
  269. };
  270. },
  271. watch: {
  272. // 根据名称筛选机构树
  273. deptName(val) {
  274. this.$refs.tree.filter(val);
  275. },
  276. },
  277. created() {
  278. this.getDeptTree();
  279. this.getConfigKey("sys.user.initPassword").then((response) => {
  280. this.initPassword = response.msg;
  281. });
  282. this.getList();
  283. },
  284. methods: {
  285. dayjs,
  286. resetQuery() {
  287. this.resetForm("queryForm");
  288. this.getList();
  289. },
  290. getLabel(options, value) {
  291. return getLabel(options, value);
  292. },
  293. //新增
  294. handleAdd(id) {
  295. this.$refs.editDialog.show(id);
  296. },
  297. /** 查询安全责任书列表 */
  298. getList() {
  299. this.loading = true;
  300. listSafetyBook(this.queryParams).then((response) => {
  301. this.dataList = response.rows;
  302. this.total = response.total;
  303. this.loading = false;
  304. });
  305. },
  306. getDeptTree() {
  307. deptTreeSelect().then((response) => {
  308. this.deptOptions = response.data;
  309. });
  310. },
  311. // 节点单击事件
  312. clickTreeNode(data) {
  313. this.queryParams.orgId = data.id;
  314. this.handleQuery();
  315. },
  316. /** 下穿状态改变*/
  317. changeCheckBox() {
  318. this.getList();
  319. },
  320. getDefaultKey(key) {
  321. this.queryParams.orgId = key;
  322. this.getList();
  323. },
  324. //单选框状态改变
  325. checkChange(state) {
  326. this.queryParams.checkSub = state;
  327. this.handleQuery();
  328. },
  329. // 筛选节点
  330. filterNode(value, data) {
  331. if (!value) return true;
  332. return data.name.indexOf(value) !== -1;
  333. },
  334. // 节点单击事件
  335. handleNodeClick(data) {
  336. this.queryParams.orgId = data.id;
  337. this.handleQuery();
  338. },
  339. /** 搜索按钮操作 */
  340. handleQuery() {
  341. this.queryParams.pageNum = 1;
  342. this.getList();
  343. },
  344. /** 删除按钮操作 */
  345. handleDelete(row) {
  346. const ids = row.id || this.ids;
  347. this.$modal
  348. .confirm("是否确认删除?")
  349. .then(function () {
  350. return delSafetyBook(ids);
  351. })
  352. .then(() => {
  353. this.getList();
  354. this.$modal.msgSuccess("删除成功");
  355. })
  356. .catch(() => {});
  357. },
  358. /** 详情按钮操作 */
  359. handleInfo(id) {
  360. this.$refs.DialogDes.show(id);
  361. },
  362. /** treeSelect组件自定义数据*/
  363. tenantIdnormalizer(node, instanceId) {
  364. if (node.children && !node.children.length) {
  365. delete node.children;
  366. }
  367. return {
  368. id: node.id,
  369. label: node.shortName,
  370. children: node.children,
  371. };
  372. },
  373. },
  374. };
  375. </script>
  376. <style lang="scss" scoped>
  377. .ellipsis {
  378. white-space: nowrap;
  379. overflow: hidden;
  380. text-overflow: ellipsis;
  381. }
  382. ::v-deep.formTreeItem {
  383. .el-form-item__content {
  384. width: 264px;
  385. }
  386. }
  387. </style>