index.vue 10 KB

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