metadata.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @selection-change="selectionChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad">
  19. <template slot="menuLeft">
  20. <div style="display:flex;align-items: center;">
  21. <div style="width:180px">文件存储类型</div>
  22. <el-select v-model="query.fileStorageType" placeholder="请选择文件存储类型"
  23. @change="queryChange">
  24. <el-option
  25. v-for="item in options"
  26. :key="item.value"
  27. :label="item.label"
  28. :value="item.value">
  29. </el-option>
  30. </el-select>
  31. <el-link :underline="false" @click="setAllocation" type="primary"><i class="el-icon-s-tools" size="large" style="line-height: 38px; font-size: 24px;margin-left: 5px;"></i></el-link>
  32. </div>
  33. </template>
  34. <template slot="menuRight" v-if="query.fileStorageType==''">
  35. <div>
  36. <el-button type="primary"
  37. icon="el-icon-plus"
  38. circle
  39. @click="toadd"></el-button>
  40. </div>
  41. </template>
  42. <template slot-scope="{type,size,row,index}" slot="menu" v-if="query.fileStorageType!==''">
  43. <el-button :size="size" :type="type" @click="cancel(row,index)" :loading="cancelLoad">取消捕获</el-button>
  44. </template>
  45. </avue-crud>
  46. <!-- 编辑元素表单信息 -->
  47. <el-dialog
  48. title="设置分类元素数据"
  49. :visible.sync="setMetadataTag"
  50. width="60%" :center='true'
  51. :modal-append-to-body="false"
  52. >
  53. <div >
  54. <div style="float:right;margin-bottom:20px">
  55. <el-select v-model="optionvalue" placeholder="请选择文件存储类型" @change="changeType">
  56. <el-option
  57. v-for="item in options"
  58. :key="item.value"
  59. :label="item.label"
  60. :value="item.value"
  61. >
  62. </el-option>
  63. </el-select>
  64. <!-- <el-button type="primary" @click="allocationSave">保存</el-button> -->
  65. </div>
  66. <el-table
  67. :data="MetadataformDatass"
  68. :row-key="selRowKey"
  69. border ref="dialogtable"
  70. style="width: 100%;">
  71. <el-table-column
  72. type="selection"
  73. reserve-selection
  74. width="55">
  75. </el-table-column>
  76. <el-table-column
  77. prop="containerName"
  78. label="元数据项">
  79. </el-table-column>
  80. <el-table-column
  81. prop="captureMode"
  82. label="捕获方式"
  83. :formatter="tableFormatter">
  84. </el-table-column>
  85. <el-table-column
  86. prop="mandatoryType"
  87. label="是否必选"
  88. :formatter="tableFormatter">
  89. </el-table-column>
  90. </el-table>
  91. <div class="text-align-c">
  92. <el-pagination
  93. @size-change="handleSizeChange"
  94. @current-change="handleCurrentChange"
  95. :current-page.sync="page2.current"
  96. :page-sizes="[20, 40, 60, 100]"
  97. :page-size="page2.pageSize"
  98. layout="total, prev, pager, next,sizes"
  99. :total="page2.total">
  100. </el-pagination>
  101. </div>
  102. </div>
  103. <span
  104. slot="footer"
  105. class="dialog-footer"
  106. >
  107. <el-button @click="setMetadataTag = false">取 消</el-button>
  108. <el-button
  109. type="primary"
  110. @click="allocationSave"
  111. :loading="saveload"
  112. >确 定</el-button>
  113. </span>
  114. </el-dialog>
  115. </basic-container>
  116. </template>
  117. <script>
  118. import {getDetail,getMetadataDetail,metadataSubmit,metadataUpdate, metadataRemove,getAllocationDetail,allocation,cancelAllocation} from "@/api/tentative/testcollect";
  119. import {mapGetters} from "vuex";
  120. export default {
  121. data() {
  122. return {
  123. options: [
  124. {
  125. value: '',
  126. label: '元数据表'
  127. },
  128. {
  129. value: 'a',
  130. label: '普通'
  131. },
  132. {
  133. value: "b",
  134. label: '竣工图'
  135. }, {
  136. value: "c",
  137. label: '计量'
  138. }, {
  139. value: "d",
  140. label: '质检'
  141. }, {
  142. value: "e",
  143. label: '声像'
  144. }, {
  145. value: "f",
  146. label: '隐蔽'
  147. }, {
  148. value: "g",
  149. label: '试验'
  150. }, {
  151. value: "h",
  152. label: '管理文件'
  153. }, {
  154. value: "i",
  155. label: '变更令'
  156. }
  157. ],
  158. optionvalue: '',
  159. form: {},
  160. query: {
  161. fileStorageType:'',
  162. },
  163. loading: true,
  164. page: {
  165. pageSize: 20,
  166. currentPage: 1,
  167. total: 0
  168. },
  169. search:{},
  170. selectionList: [],
  171. option: {
  172. refreshBtn: false, // 刷新
  173. columnBtn: false, // 操作列显隐
  174. cellBtn:true,//开启行编辑按钮
  175. addBtn:false,
  176. menuWidth:330,
  177. height:'auto',
  178. calcHeight: 30,
  179. tip: false,
  180. searchShow: false,
  181. searchMenuSpan: 0,
  182. border: true,
  183. index:true,
  184. indexLabel:'序号',
  185. viewBtn: true,
  186. selection: false,
  187. dialogClickModal: false,
  188. labelWidth:150,
  189. column: [
  190. {
  191. label: "元数据项",
  192. prop: "containerName",
  193. rules: [{
  194. required: true,
  195. message: "请输入元数据项",
  196. trigger: "blur"
  197. }],
  198. cell: true,
  199. },
  200. {
  201. label: "编号",
  202. prop: "code",
  203. rules: [{
  204. required: true,
  205. message: "编号",
  206. trigger: "blur"
  207. }],
  208. cell: true,
  209. },
  210. {
  211. label: "数据类型",
  212. prop: "fieldType",
  213. type:'select',
  214. dicData:[
  215. // {
  216. // label:'数值',
  217. // value:0
  218. // },
  219. {
  220. label:'字符串',
  221. value:1
  222. },
  223. {
  224. label:'日期',
  225. value:4
  226. }
  227. ],
  228. rules: [{
  229. required: true,
  230. message: "数据类型",
  231. trigger: "blur"
  232. }],
  233. cell: true,
  234. },
  235. {
  236. label: "所属容器分类",
  237. prop: "containerType",
  238. type:'select',
  239. rules: [{
  240. required: true,
  241. message: "所属容器分类",
  242. trigger: "blur"
  243. }],
  244. dicData:[
  245. {label:'无',value:100},
  246. {label:'来源',value:0},
  247. {label:'文件联',value:1
  248. },{label:'内容描述',value:2},
  249. {label:'文件标识码',value:3},
  250. {label:'照片文件',value:4},
  251. {label:'电子属性',value:5},
  252. {label:'数字化属性',value:6},
  253. {label:'电子签名',value:7},
  254. {label:'竣工图',value:8},
  255. {label:'业务层级',value:9},
  256. ],
  257. cell: true,
  258. },
  259. {
  260. label: "捕获方式",
  261. prop: "captureMode",
  262. rules: [{
  263. required: true,
  264. message: "捕获方式",
  265. trigger: "blur"
  266. }],
  267. type:'select',
  268. dicData:[{
  269. label:'手动',
  270. value:0
  271. },{
  272. label:'自动',
  273. value:1
  274. },{
  275. label:'手动/自动',
  276. value:2
  277. }],
  278. cell: true,
  279. },
  280. {
  281. label: "是否必选",
  282. prop: "mandatoryType",
  283. rules: [{
  284. required: true,
  285. message: "是否必选",
  286. trigger: "blur"
  287. }],
  288. type:'select',
  289. dicData:[{
  290. label:'可选',
  291. value:0
  292. },{
  293. label:'必选',
  294. value:1
  295. },{
  296. label:'条件选',
  297. value:2
  298. }],
  299. cell: true,
  300. }
  301. ]
  302. },
  303. data: [],
  304. setMetadataTag:false,
  305. MetadataformDatass:[],
  306. page2:{
  307. pageSize:20,
  308. total:0,
  309. current:1,
  310. },
  311. isShowedit:true,
  312. saveload:false,
  313. cancelLoad:false
  314. };
  315. },
  316. computed: {
  317. ...mapGetters(["permission"]),
  318. permissionList() {
  319. return {
  320. viewBtn: false,
  321. addBtn: this.isShowedit,
  322. delBtn: this.isShowedit,
  323. editBtn: this.isShowedit,
  324. };
  325. },
  326. ids() {
  327. let ids = [];
  328. this.selectionList.forEach(ele => {
  329. ids.push(ele.id);
  330. });
  331. return ids.join(",");
  332. }
  333. },
  334. methods: {
  335. rowSave(row, done, loading) {
  336. row.fileStorageType = this.query.fileStorageType;
  337. metadataSubmit(row).then(() => {
  338. this.onLoad(this.page);
  339. this.$message({
  340. type: "success",
  341. message: "操作成功!"
  342. });
  343. done();
  344. }, error => {
  345. loading();
  346. window.console.log(error);
  347. });
  348. },
  349. rowUpdate(row, index, done, loading) {
  350. row.fileStorageType = this.query.fileStorageType;
  351. metadataUpdate(row).then(() => {
  352. this.onLoad(this.page);
  353. this.$message({
  354. type: "success",
  355. message: "操作成功!"
  356. });
  357. done();
  358. }, error => {
  359. loading();
  360. console.log(error);
  361. });
  362. },
  363. rowDel(row) {
  364. this.$confirm("确定将选择数据删除?", {
  365. confirmButtonText: "确定",
  366. cancelButtonText: "取消",
  367. type: "warning"
  368. })
  369. .then(() => {
  370. return metadataRemove(row.id);
  371. })
  372. .then(() => {
  373. this.onLoad(this.page);
  374. this.$message({
  375. type: "success",
  376. message: "操作成功!"
  377. });
  378. });
  379. },
  380. beforeOpen(done, type) {
  381. if (["edit", "view"].includes(type)) {
  382. getDetail(this.form.id).then(res => {
  383. this.form = res.data.data;
  384. });
  385. }
  386. done();
  387. },
  388. searchReset() {
  389. this.query = {};
  390. this.onLoad(this.page);
  391. },
  392. searchChange(params, done) {
  393. this.query = params;
  394. this.page.currentPage = 1;
  395. this.onLoad(this.page, params);
  396. done();
  397. },
  398. selectionChange(list) {
  399. this.selectionList = list;
  400. },
  401. selectionClear() {
  402. this.selectionList = [];
  403. if(this.$refs.crud){
  404. this.$refs.crud.toggleSelection();
  405. }
  406. },
  407. currentChange(currentPage){
  408. this.page.currentPage = currentPage;
  409. },
  410. sizeChange(pageSize){
  411. this.page.pageSize = pageSize;
  412. },
  413. refreshChange() {
  414. this.onLoad(this.page, this.query);
  415. },
  416. onLoad(page, params = {}) {
  417. this.loading = true;
  418. getMetadataDetail(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  419. const data = res.data.data;
  420. data.records.forEach((item)=>{
  421. item.fieldType = Number(item.fieldType)
  422. })
  423. this.page.total = data.total;
  424. this.data = data.records;
  425. this.loading = false;
  426. this.selectionClear();
  427. });
  428. // const data = [{
  429. // metadataitem:'全宗名称',
  430. // id:'1',
  431. // datatype:'字符串',
  432. // containertype:'来源',
  433. // capture:'手动',
  434. // isrequired:'是',
  435. // }];
  436. //this.page.total = 1;
  437. // this.data = data;
  438. this.loading = false;
  439. this.selectionClear();
  440. },
  441. setMetadata(){
  442. console.log(this.selectionList,'this.selectionList');
  443. if (this.selectionList.length === 0) {
  444. this.$message.warning("请选择至少一条数据");
  445. return;
  446. }
  447. if (this.data.length) {
  448. let da = []
  449. this.MetadataformDatass = [...this.selectionList];
  450. console.log(this.MetadataformDatass,'his.formDatass111');
  451. // this.MetadataformDatass.forEach(val => {
  452. // da.push({
  453. // tableType: val.tabType,
  454. // tableOwner: val.tabOwner,
  455. // id: val.id,
  456. // tableName: val.title,
  457. // fillRate: val.fillRate,
  458. // })
  459. // })
  460. // this.MetadataformDatass = da
  461. // console.log(this.MetadataformDatass,'this.formDatass');
  462. // let fa=[]
  463. // this.MetadataformDatass.forEach(val=>{
  464. // let newarr= this.tableTypelist.filter(e => e.dictValue===val.tableType);
  465. // let newarr1= this.ownerTypeList.filter(e => e.dictValue===val.tableOwner);
  466. // fa.push({
  467. // tableType: newarr[0].dictKey,
  468. // tableOwner: newarr1[0].dictKey,
  469. // id: val.id,
  470. // tableName: val.tableName,
  471. // fillRate: val.fillRate,
  472. // })
  473. // })
  474. // this.MetadataformDatass=fa
  475. }
  476. this.setMetadataTag=true;
  477. },
  478. //新增一条数据
  479. toadd(){
  480. this.$refs.crud.rowCellAdd()
  481. //console.log(this.$refs.crud.rowCellAdd())
  482. },
  483. //切换选项
  484. queryChange(val){
  485. this.page.currentPage = 1;
  486. this.onLoad(this.page);
  487. if(val!==''){
  488. this.isShowedit=false
  489. }else{
  490. this.isShowedit=true
  491. }
  492. },
  493. setAllocation(){
  494. this.setMetadataTag=true;
  495. this.$nextTick(()=>{
  496. this.$refs.dialogtable.clearSelection();
  497. })
  498. this.getAllocationList();
  499. this.optionvalue=''
  500. // this.optionvalue = this.query.fileStorageType;
  501. },
  502. //为行设置独有key
  503. selRowKey(row){
  504. // console.log(row);
  505. return row.id
  506. },
  507. getAllocationList(){
  508. getAllocationDetail(this.page2.current,this.page2.pageSize,{
  509. fileStorage:''
  510. }).then((res)=>{
  511. //console.log(res)
  512. const data = res.data.data;
  513. this.MetadataformDatass = data.records;
  514. this.page2.total = data.total;
  515. let checkarr=[]
  516. if(this.optionvalue!==''){
  517. checkarr=this.MetadataformDatass.filter((item)=>{
  518. if(item.fileStorageType.indexOf(this.optionvalue)!==-1){
  519. return item
  520. }
  521. })
  522. }
  523. this.$nextTick(()=>{
  524. checkarr.forEach((ele)=>{
  525. this.$refs.dialogtable.toggleRowSelection(ele,true);
  526. })
  527. })
  528. })
  529. },
  530. handleCurrentChange(index){
  531. this.page2.current = index;
  532. this.getAllocationList();
  533. },
  534. handleSizeChange(val) {
  535. console.log(val,'val');
  536. this.page2.pageSize = val;
  537. this.getAllocationList();
  538. },
  539. tableFormatter(row, column, cellValue){
  540. //console.log(row,'row');
  541. //console.log(column,'column');
  542. //console.log(cellValue,'cellValue');
  543. let obj = {}
  544. if(column.property == 'captureMode'){
  545. obj = {
  546. 0:'手动',
  547. 1:'自动',
  548. 2:'手动/自动',
  549. }
  550. }else if(column.property == 'mandatoryType'){
  551. obj = {
  552. 0:'可选',
  553. 1:'必选',
  554. 2:'条件选',
  555. }
  556. }
  557. return obj[cellValue];
  558. },
  559. //修改文件类型储存
  560. allocationSave(){
  561. let list = [];
  562. list = this.$refs.dialogtable.selection;
  563. //console.log(list)
  564. // if (list.length === 0) {
  565. // this.$message.warning("请选择至少一条数据");
  566. // return;
  567. // }
  568. let ids = [];
  569. list.forEach((item)=>{
  570. ids.push(item.id)
  571. })
  572. this.saveload=true
  573. allocation({
  574. ids:ids.join(','),
  575. type:this.optionvalue
  576. }).then(()=>{
  577. this.$message.success('操作成功');
  578. this.saveload=false
  579. this.handleCurrentChange(1);
  580. this.queryChange();
  581. this.setMetadataTag=false
  582. })
  583. this.optionvalue=''
  584. },
  585. //取消捕获
  586. cancel(row){
  587. this.cancelLoad=true
  588. cancelAllocation({
  589. ids:row.id,
  590. type:this.query.fileStorageType
  591. }).then(()=>{
  592. this.cancelLoad=false
  593. this.handleCurrentChange(1);
  594. this.queryChange();
  595. })
  596. },
  597. //回显选择
  598. changeType(val){
  599. this.page2.current = 1;
  600. this.$refs.dialogtable.clearSelection();
  601. this.getAllocationList()
  602. }
  603. }
  604. };
  605. </script>
  606. <style>
  607. </style>