index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /** 应用管理 author:laiyh date:2020-10-28 */
  2. <template>
  3. <dg-row>
  4. <dg-col :span="5">
  5. <tree
  6. class="u-pm__left"
  7. title="机构列表"
  8. :apiName="`getAllorgTree`"
  9. :params="treeProps"
  10. @handleGetNode="handleGetNode"
  11. @submitRootNode="submitRootNode"
  12. />
  13. </dg-col>
  14. <dg-col :span="19">
  15. <div class="u-right__table">
  16. <el-form ref="form" class="search-bar" :model="formData" label-position="left" label-suffix="" label-width="75px">
  17. <dg-row :gutter="12">
  18. <dg-col :span="6">
  19. <el-form-item label="应用状态" prop="applyStatus.value">
  20. <dg-select
  21. v-model="formData.applyStatus.value"
  22. code="DM_APPLY_STATUS"
  23. placeholder="请选择应用状态"
  24. filterable
  25. clearable
  26. />
  27. </el-form-item>
  28. </dg-col>
  29. <dg-col :span="6">
  30. <el-form-item label="应用代码" prop="applyCode.value">
  31. <el-input
  32. v-model="formData.applyCode.value"
  33. placeholder="请输入应用代码"
  34. clearable
  35. @keyup.enter.native="doSearch"
  36. />
  37. </el-form-item>
  38. </dg-col>
  39. <dg-col :span="6">
  40. <el-form-item label="承建单位" prop="manufacturerName.value">
  41. <el-input
  42. v-model="formData.manufacturerName.value"
  43. placeholder="请输入承建单位"
  44. clearable
  45. @keyup.enter.native="doSearch"
  46. />
  47. </el-form-item>
  48. </dg-col>
  49. <dg-col :span="6">
  50. <dg-button type="primary" icon="el-icon-search" @click="doSearch">查询</dg-button>
  51. <dg-button icon="el-icon-refresh-right" @click="hanldleReset">重置</dg-button>
  52. </dg-col>
  53. </dg-row>
  54. <dg-row :gutter="12">
  55. <dg-col :span="6">
  56. <el-form-item label="业务警种" prop="policeSpecies.value">
  57. <dg-select
  58. v-model="formData.policeSpecies.value"
  59. clearable
  60. filterable
  61. code="T_MD_POLICE_TYPE"
  62. placeholder="请选择所属业务警种"
  63. />
  64. </el-form-item>
  65. </dg-col>
  66. <dg-col :span="6">
  67. <el-form-item label="应用名称" prop="applyName.value">
  68. <el-input v-model="formData.applyName.value" placeholder="请输入应用名称" clearable />
  69. </el-form-item>
  70. </dg-col>
  71. <dg-col :span="10">
  72. <el-form-item label="注册日期" prop="registrationTime.value">
  73. <dg-date-picker
  74. v-model="formData.registrationTime.value"
  75. align="right"
  76. type="daterange"
  77. placeholder="请选择注册日期"
  78. :picker-options="pickerOptions"
  79. clearable
  80. value-format="yyyy-MM-dd"
  81. range-separator="至"
  82. start-placeholder="开始日期"
  83. end-placeholder="结束日期"
  84. />
  85. </el-form-item>
  86. </dg-col>
  87. </dg-row>
  88. </el-form>
  89. <!-- 操作栏 -->
  90. <operate-bar :pageOptList="pageOptList" @submitPageOpt="receviceOpt"></operate-bar>
  91. <!-- 表格 -->
  92. <Table ref="myTable" :url="tableUrl" :headerData="titleData" :condition="formData" :lazyLoad="true">
  93. <dg-table-column fixed="right" label="操作" width="120" align="center">
  94. <template slot-scope="scope">
  95. <div class="u-table__operation">
  96. <el-tooltip
  97. v-for="(item, i) in optList"
  98. :key="'table' + i"
  99. :content="item.tooltip"
  100. effect="dark"
  101. placement="top-end"
  102. >
  103. <i :class="item.icon" @click="item.on(scope.row)" />
  104. </el-tooltip>
  105. </div>
  106. </template>
  107. </dg-table-column>
  108. </Table>
  109. </div>
  110. </dg-col>
  111. </dg-row>
  112. </template>
  113. <script>
  114. import Tree from '@/pages/common/tree';
  115. import Table from '@/pages/common/table';
  116. import { appRestApi, select, getRemoteRource, syncRource } from '@/api/application';
  117. import Editor from './editor';
  118. import Detail from './detail';
  119. import operateBar from '@/components/operate-bar';
  120. const editorArea = ['960px', '680px'];
  121. import { mapGetters } from 'vuex';
  122. export default {
  123. name: 'appMSG',
  124. components: { Tree, Table, operateBar },
  125. computed: {
  126. ...mapGetters(['user'])
  127. },
  128. mounted() {},
  129. data() {
  130. const that = this;
  131. return {
  132. tableUrl: appRestApi.table,
  133. pickerOptions: {
  134. disabledDate(time) {
  135. return time.getTime() > Date.now();
  136. }
  137. },
  138. treeProps: {
  139. type: '0'
  140. },
  141. formData: {
  142. registrationTime: { value: '', op: 'between', type: 'DATE', format: 'yyyy-MM-dd' },
  143. applyStatus: { value: '', op: '=' }, // 应用状态
  144. applyCode: { value: '', op: 'like' }, // 应用代码
  145. manufacturerName: { value: '', op: 'like' }, // 承建单位
  146. policeSpecies: { value: '', op: '=' }, // 所属业务警种
  147. applyName: { value: '', op: 'like' }, // 应用名称
  148. orgId: { value: '', op: '=' } // 组织结构
  149. },
  150. titleData: [
  151. { label: '应用名称', prop: 'applyName', width: 120 },
  152. { label: '应用代码', prop: 'applyCode', width: 120 },
  153. { label: '应用负责人', prop: 'fzr', width: 120 },
  154. { label: '应用负责人电话', prop: 'fzrPhone', width: 140 },
  155. { label: '建设单位负责人', prop: 'jgFzr', width: 140 },
  156. { label: '建设单位负责人电话', prop: 'jgFzrPhone', width: 180 },
  157. { label: '所属业务警种', prop: 'policeSpecies', width: 120, code: 'T_MD_POLICE_TYPE' },
  158. { label: '承建单位', prop: 'manufacturerName', width: 120 },
  159. { label: '建设单位', prop: 'orgName', width: 120 },
  160. { label: '注册时间', prop: 'registrationTime', width: 120 }
  161. ],
  162. optList: [
  163. { icon: 'el-icon-edit', tooltip: '修改', on: that.handleEditor },
  164. { icon: 'el-icon-document', tooltip: '详情', on: that.handleDetail },
  165. { icon: 'el-icon-delete', tooltip: '删除', on: that.handleDelete }
  166. ],
  167. pageOptList: ['新增', '资源获取', '资源同步']
  168. };
  169. },
  170. methods: {
  171. receviceOpt(opt) {
  172. if (opt == '新增') {
  173. this.handleAddDialog();
  174. } else if (opt == '资源获取') {
  175. this.handleRemoteResource();
  176. } else if (opt == '资源获取') {
  177. this.handleSyncResource();
  178. }
  179. },
  180. handleGetNode({ id }) {
  181. const that = this;
  182. const oldVal = that.formData.orgId.value;
  183. if (oldVal != id) {
  184. that.formData.orgId.value = id;
  185. that.handleSearch();
  186. }
  187. },
  188. // 默认查询跟节点
  189. submitRootNode({ id, name }) {
  190. const that = this;
  191. this.$nextTick(() => {
  192. that.handleGetNode({ id, name });
  193. });
  194. },
  195. reloadTable() {
  196. const that = this;
  197. that.$refs.myTable.$refs.grid.reload();
  198. },
  199. handleSearch() {
  200. this.$refs.myTable.handleSearchClick();
  201. },
  202. doSearch() {
  203. this.formData.orgId.value = '';
  204. this.handleSearch();
  205. },
  206. hanldleReset() {
  207. const that = this;
  208. that.formData.orgId.value = '';
  209. this.$refs.form.resetFields();
  210. },
  211. success(message = '操作成功!') {
  212. const that = this;
  213. that.$message.success(message);
  214. },
  215. fail(message = '操作失败', error) {
  216. const that = this;
  217. console.error('[Error]', error);
  218. that.$message.error(message);
  219. },
  220. handleAddDialog() {
  221. const that = this;
  222. const layer = that.$dgLayer({
  223. title: '添加',
  224. shade: [0.4, '#FFF'],
  225. content: Editor,
  226. props: { type: 'create' },
  227. area: editorArea,
  228. on: {
  229. success(bool = false) {
  230. layer.close(layer.dialogIndex);
  231. if (bool) {
  232. that.reloadTable();
  233. }
  234. }
  235. }
  236. });
  237. },
  238. handleEditor({ id }) {
  239. const that = this;
  240. appRestApi
  241. .detail(id)
  242. .then((res) => {
  243. const layer = that.$dgLayer({
  244. title: '修改',
  245. shade: [0.4, '#FFF'],
  246. area: editorArea,
  247. content: Editor,
  248. props: {
  249. type: 'update',
  250. formData: res,
  251. translateData: [{ value: res.orgId, label: res.orgName }]
  252. },
  253. on: {
  254. success(bool = false) {
  255. layer.close(layer.dialogIndex);
  256. if (bool) {
  257. that.reloadTable();
  258. }
  259. }
  260. }
  261. });
  262. })
  263. .catch((error) => {
  264. that.fail('详情获取失败!', error);
  265. });
  266. },
  267. handleDetail({ id }) {
  268. const that = this;
  269. appRestApi
  270. .detail(id)
  271. .then((res) => {
  272. const layer = that.$dgLayer({
  273. title: '详情',
  274. shade: [0.4, '#FFF'],
  275. content: Detail,
  276. props: {
  277. formData: res,
  278. translateData: [{ value: res.orgId, label: res.orgName }]
  279. },
  280. on: {
  281. success() {
  282. layer.close(layer.dialogIndex);
  283. }
  284. },
  285. area: editorArea
  286. });
  287. })
  288. .catch((error) => {
  289. that.fail('详情获取失败!', error);
  290. });
  291. },
  292. handleDelete({ id }) {
  293. const that = this;
  294. that
  295. .$confirm('是否确认删除?', '提示', {
  296. distinguishCancelAndClose: true,
  297. confirmButtonText: '确定',
  298. cancelButtonText: '取消'
  299. })
  300. .then(() => {
  301. appRestApi
  302. .del(id)
  303. .then(() => {
  304. that.reloadTable();
  305. that.success('删除成功!');
  306. })
  307. .catch((error) => {
  308. that.fail(error); // 直接提示后端错误信息
  309. });
  310. });
  311. },
  312. // 获取资源
  313. handleRemoteResource() {
  314. const that = this;
  315. const queryParams = {
  316. listingAll: true
  317. };
  318. getRemoteRource(queryParams)
  319. .then((res) => {
  320. that.$message.success('资源获取成功!');
  321. })
  322. .catch((err) => {
  323. that.$message.error(err);
  324. });
  325. },
  326. handleSyncResource() {
  327. const that = this;
  328. syncRource()
  329. .then((res) => {
  330. that.$message.success('资源同步成功!');
  331. })
  332. .catch((err) => {
  333. that.$message.error(err);
  334. });
  335. }
  336. },
  337. created() {
  338. const that = this;
  339. // select()
  340. // .then(res => {
  341. // debugger
  342. // })
  343. // .catch(err => {
  344. // that.fail('获取认证因子失败!', err);
  345. // })
  346. }
  347. };
  348. </script>