file-sort.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <ele-modal
  3. top="5vh"
  4. width="1100px"
  5. :visible="visible"
  6. title="卷内文件调整"
  7. :close-on-click-modal="false"
  8. custom-class="demo-file-sort-dialog"
  9. @update:visible="updateVisible"
  10. >
  11. <el-row :gutter="15">
  12. <el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
  13. <ele-pro-table
  14. ref="docTable"
  15. sub-title="案卷列表"
  16. :datasource="documents"
  17. :columns="columns1"
  18. highlight-current-row
  19. height="400px"
  20. :toolkit="[]"
  21. :need-page="false"
  22. :current.sync="current"
  23. class="demo-file-sort-table"
  24. :tool-style="{ lineHeight: '28px' }"
  25. @done="onDocTbDone"
  26. >
  27. </ele-pro-table>
  28. </el-col>
  29. <el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
  30. <ele-pro-table
  31. ref="fileTable"
  32. :loading="loading"
  33. sub-title="卷内列表"
  34. :datasource="data1"
  35. :columns="columns2"
  36. height="400px"
  37. :selection.sync="selection1"
  38. :need-page="false"
  39. :toolkit="[]"
  40. >
  41. <template v-slot:toolkit>
  42. <el-button
  43. type="primary"
  44. icon="el-icon-top"
  45. class="ele-btn-icon"
  46. size="mini"
  47. @click="moveUp"
  48. >
  49. 上移
  50. </el-button>
  51. <el-button
  52. type="primary"
  53. icon="el-icon-bottom"
  54. class="ele-btn-icon"
  55. size="mini"
  56. @click="moveDown"
  57. >
  58. 下移
  59. </el-button>
  60. <el-button
  61. type="primary"
  62. icon="el-icon-top-right"
  63. class="ele-btn-icon"
  64. size="mini"
  65. @click="moveOut"
  66. >
  67. 调出
  68. </el-button>
  69. </template>
  70. </ele-pro-table>
  71. </el-col>
  72. <el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
  73. <ele-pro-table
  74. :loading="loading"
  75. sub-title="未归档列表"
  76. :datasource="data2"
  77. :columns="columns2"
  78. height="400px"
  79. :selection.sync="selection2"
  80. :need-page="false"
  81. :toolkit="[]"
  82. >
  83. <template v-slot:toolkit>
  84. <el-button
  85. type="primary"
  86. icon="el-icon-top-left"
  87. class="ele-btn-icon"
  88. size="mini"
  89. @click="moveIn"
  90. >
  91. 调入
  92. </el-button>
  93. </template>
  94. </ele-pro-table>
  95. </el-col>
  96. </el-row>
  97. <template v-slot:footer>
  98. <div>
  99. <el-button @click="close">取消</el-button>
  100. <el-button type="primary" @click="save">保存</el-button>
  101. </div>
  102. </template>
  103. </ele-modal>
  104. </template>
  105. <script>
  106. import { getArchiveList } from '@/api/example/document';
  107. export default {
  108. props: {
  109. // 弹窗是否打开
  110. visible: Boolean,
  111. // 案卷列表
  112. documents: {
  113. type: Array,
  114. required: true
  115. }
  116. },
  117. data() {
  118. return {
  119. // 加载loading
  120. loading: true,
  121. // 案卷表格列配置
  122. columns1: [
  123. {
  124. prop: 'title',
  125. label: '案卷题名',
  126. width: 110,
  127. showOverflowTooltip: true
  128. },
  129. {
  130. prop: 'piece_no',
  131. label: '案卷档号',
  132. showOverflowTooltip: true
  133. }
  134. ],
  135. // 卷内表格列配置
  136. columns2: [
  137. {
  138. columnKey: 'selection',
  139. type: 'selection',
  140. width: 45,
  141. align: 'center'
  142. },
  143. {
  144. prop: 'title',
  145. label: '文件题名',
  146. width: 110,
  147. showOverflowTooltip: true
  148. },
  149. {
  150. prop: 'archive_no',
  151. label: '文件档号',
  152. showOverflowTooltip: true
  153. }
  154. ],
  155. // 案卷下的全部文件列表
  156. data: [],
  157. // 选中案卷
  158. current: null,
  159. // 卷内列表选中数据
  160. selection1: [],
  161. // 未归档列表选中数据
  162. selection2: []
  163. };
  164. },
  165. computed: {
  166. // 选中案卷的卷内文件
  167. data1() {
  168. if (!this.current) {
  169. return [];
  170. }
  171. return this.data.filter((d) => d.piece_no === this.current.piece_no);
  172. },
  173. // 未归档的卷内文件
  174. data2() {
  175. return this.data.filter((d) => !d.piece_no);
  176. },
  177. // 是否开启响应式布局
  178. styleResponsive() {
  179. return this.$store.state.theme.styleResponsive;
  180. }
  181. },
  182. methods: {
  183. onDocTbDone() {
  184. if (this.documents.length) {
  185. this.$refs.docTable.setCurrentRow(this.documents[0]);
  186. }
  187. },
  188. /* 查询所选案卷的卷内文件 */
  189. query() {
  190. this.loading = true;
  191. getArchiveList({
  192. pieceNoIn: this.documents.map((d) => d.piece_no)
  193. })
  194. .then((data) => {
  195. this.loading = false;
  196. this.data = data;
  197. })
  198. .catch((e) => {
  199. this.loading = false;
  200. // this.$message.error(e.message);
  201. });
  202. },
  203. /* 上移 */
  204. moveUp() {
  205. if (!this.selection1.length) {
  206. this.$message.error('请选择一条数据');
  207. return;
  208. }
  209. if (this.selection1.length > 1) {
  210. this.$message.error('只能选择一条数据');
  211. return;
  212. }
  213. if (this.data1.indexOf(this.selection1[0]) === 0) {
  214. return;
  215. }
  216. const index = this.data.indexOf(this.selection1[0]);
  217. const temp = this.data[index - 1];
  218. this.$set(this.data, index - 1, this.selection1[0]);
  219. this.$set(this.data, index, temp);
  220. this.$nextTick(() => {
  221. this.$refs.fileTable.toggleRowSelection(this.data[index - 1], true);
  222. });
  223. },
  224. /* 下移 */
  225. moveDown() {
  226. if (!this.selection1.length) {
  227. this.$message.error('请选择一条数据');
  228. return;
  229. }
  230. if (this.selection1.length > 1) {
  231. this.$message.error('只能选择一条数据');
  232. return;
  233. }
  234. if (this.data1.indexOf(this.selection1[0]) === this.data1.length - 1) {
  235. return;
  236. }
  237. const index = this.data.indexOf(this.selection1[0]);
  238. const temp = this.data[index + 1];
  239. this.$set(this.data, index + 1, this.selection1[0]);
  240. this.$set(this.data, index, temp);
  241. this.$nextTick(() => {
  242. this.$refs.fileTable.toggleRowSelection(this.data[index + 1], true);
  243. });
  244. },
  245. /* 调出 */
  246. moveOut() {
  247. if (!this.selection1.length) {
  248. this.$message.error('请至少选择一条数据');
  249. return;
  250. }
  251. this.selection1.forEach((d) => {
  252. d.piece_no = '';
  253. });
  254. },
  255. /* 调入 */
  256. moveIn() {
  257. if (!this.current) {
  258. return;
  259. }
  260. if (!this.selection2.length) {
  261. this.$message.error('请至少选择一条数据');
  262. return;
  263. }
  264. this.selection2.forEach((d) => {
  265. d.piece_no = this.current.piece_no;
  266. });
  267. },
  268. /* 保存 */
  269. save() {
  270. const result = this.data.map((d) => {
  271. return {
  272. archive_no: d.archive_no,
  273. piece_no: d.piece_no
  274. };
  275. });
  276. console.log(result);
  277. this.updateVisible(false);
  278. },
  279. /* 关闭弹窗 */
  280. close() {
  281. this.updateVisible(false);
  282. },
  283. /* 更新visible */
  284. updateVisible(value) {
  285. this.$emit('update:visible', value);
  286. }
  287. },
  288. watch: {
  289. visible(visible) {
  290. if (visible) {
  291. this.query();
  292. } else {
  293. this.data = [];
  294. }
  295. }
  296. }
  297. };
  298. </script>
  299. <style lang="scss" scoped>
  300. :deep(.demo-file-sort-dialog) {
  301. margin-bottom: 5vh;
  302. .el-dialog__body {
  303. padding-top: 15px;
  304. padding-bottom: 0;
  305. & > .el-row > .el-col {
  306. margin-bottom: 15px;
  307. }
  308. }
  309. }
  310. .demo-file-sort-table {
  311. :deep(.el-table__row) {
  312. cursor: pointer;
  313. }
  314. :deep(.el-table__row > td:last-child) {
  315. &:after {
  316. content: '\e6e0';
  317. font-family: element-icons !important;
  318. font-style: normal;
  319. font-variant: normal;
  320. text-transform: none;
  321. -webkit-font-smoothing: antialiased;
  322. -moz-osx-font-smoothing: grayscale;
  323. line-height: 1;
  324. position: absolute;
  325. right: 10px;
  326. top: 50%;
  327. margin-top: -7px;
  328. }
  329. .cell {
  330. padding-right: 20px;
  331. }
  332. }
  333. }
  334. </style>