| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <template>
- <div class="grid-container-2">
- <div class="grid-header-2">
- <QueryCondition
- ref="queryCondition"
- :info-filter-fields="infoFilterFields"
- :show-button="true"
- :is-search-widget="true"
- @simple-search="simpleSearch()"
- @complex-search="complexSearch()"
- @refresh-search="queryInfoWindowData"
- @change-search="tabIndex = 1;"
- >
- <template #header>
- <li
- role="presentation"
- :class="{'active': tabIndex === 2}"
- >
- <a @click="$refs.queryCondition.changeSearch(1); tabIndex = 2;">{{ $t('lang.DocGenerator.selectedDatas') }}</a>
- </li>
- </template>
- <template #body>
- <div
- class="tab-pane"
- :class="{'active': tabIndex === 2}"
- />
- </template>
- </QueryCondition>
- </div>
- <div class="grid-content-2">
- <DocGeneratorGrid
- v-show="tabIndex === 1"
-
- ref="docGeneratorGrid"
- :info-window-no="infoWindowNo"
- :info-grid-fields="infoGridFields"
- :info-window-data="infoWindowData"
- :is-selected-by-id="isSelectedById"
- @refresh-search="queryInfoWindowData"
- @select-changed="selectChanged"
- />
- <DocGeneratorSelected
- v-show="tabIndex === 2"
- ref="docGeneratorSelected"
- :info-window-no="infoWindowNo"
- :info-grid-fields="infoGridFields"
- @select-changed="queryInfoWindowData"
- />
- </div>
- <Loading ref="loading" />
- </div>
- </template>
- <script>
- var Common = require('../../common/Common.js').default;
- var InfoUtil = require('./InfoUtil.js').default;
- var Loading = require('../../loading/src/Loading.vue').default;
- var QueryCondition = require('./QueryCondition.vue').default;
- var DocGeneratorSelected = require('./DocGeneratorSelected.vue').default;
- var DocGeneratorGrid = require('./DocGeneratorGrid.vue').default;
- export default {
- name: 'DocGenerator',
- components: {
- QueryCondition, Loading,
- DocGeneratorSelected,
- DocGeneratorGrid,
- },
-
- props: ['infoWindowNo'],
- data: function () {
- return {
- infoWindowDto: {},
- infoFilterFields: [], // 过滤字段
- infoGridFields: [], // 表格字段
- infoWindowData: [],
- tabIndex: 1,
- };
- },
- watch: {
- infoWindowNo: function(newValue, oldValue){
- this.init();
- },
- },
- mounted: function(){
- this.init();
- },
- methods: {
-
- /**
- * 加载查询窗口的定义
- * @author YangZhiJie 20210909
- */
- init: function () {
- var _self = this;
- if (_self.infoWindowNo === undefined || _self.infoWindowNo === null || _self.infoWindowNo === '') {
- return;
- }
- _self.$refs.loading.show();
- $.ajax({
- url: Common.getApiURL('InfoWindowResource/uniqueByNo'),
- type: 'GET',
- dataType: 'json',
- data: { 'infoWindowNo': _self.infoWindowNo },
- beforeSend: function (request) {
- Common.addTokenToRequest(request);
- },
- success: function (data) {
- _self.$refs.loading.show();
- _self.infoWindowDto = data;
- _self.$emit('showTitle', data.name);
- _self.$nextTick(function () {
- _self.initQueryPage();
- });
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- _self.$refs.loading.show();
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
- },
- });
- },
- /**
- * 根据用户配置更新查询窗口的定义
- * @author YangZhiJie 20210909
- */
- initQueryPage: function () {
- var _self = this;
- if (_self.infoWindowDto === undefined || _self.infoWindowDto === null) {
- return;
- }
-
- _self.infoWindowDto.infoGridFields.forEach(function (item) {
- _self.$set(item, 'width', 150);
- });
- _self.infoWindowDto.infoFilterFields.forEach(function (item) {
- item.value = {
- 'infoFilterFieldId': item.id,
- 'value1': '',
- 'value2': '',
- };
- });
-
- InfoUtil.restoreInfoFilterField(_self.infoWindowDto.no, _self.infoWindowDto.infoFilterFields);
- InfoUtil.restoreInfoGridField(_self.infoWindowDto.no, _self.infoWindowDto.infoGridFields);
- _self.infoFilterFields = _self.infoWindowDto.infoFilterFields;
- _self.infoGridFields = _self.infoWindowDto.infoGridFields;
- _self.$nextTick(function () {
- _self.queryInfoWindowData();
- });
- },
- /**
- * 重新开始简单查询
- * @author YangZhiJie 20210909
- */
- simpleSearch: function () {
- this.$refs.docGeneratorGrid.resetPagination();
- this.queryInfoWindowDataSimple();
- },
- /**
- * 从新开始复杂查询
- * @author YangZhiJie 20210909
- */
- complexSearch: function () {
- this.$refs.docGeneratorGrid.resetPagination();
- this.queryInfoWindowDataComplex();
- },
- /**
- * 查询窗口数据查询
- * @author YangZhiJie 20210909
- */
- queryInfoWindowData: function () {
- var isSimpleSearch = this.$refs.queryCondition.isSimpleQuery();
- if (isSimpleSearch) {
- this.queryInfoWindowDataSimple();
- } else {
- this.queryInfoWindowDataComplex();
- }
- },
- /**
- * 简单数据查询
- * @author YangZhiJie 20210909
- */
- queryInfoWindowDataSimple: function () {
- var _self = this;
- var infoQueryParam = this.$refs.docGeneratorGrid.getQueryParam();
- infoQueryParam.infoFilterFieldValues = _self.$refs.queryCondition.getQueryCondition();
- _self.$refs.loading.show();
- $.ajax({
- url: Common.getApiURL('InfoWindowResource/queryInfoWindowDataSimple'),
- type: 'post',
- dataType: 'json',
- beforeSend: function (request) {
- Common.addTokenToRequest(request);
- },
- contentType: 'application/json',
- data: JSON.stringify(infoQueryParam),
- success: function (data) {
- _self.$refs.loading.hide();
- console.log(data);
- if (data != undefined && data.range != undefined) {
- _self.infoWindowData = data.dataList;
- _self.$refs.docGeneratorGrid.setPagination(data.totalSize, Math.ceil(data.totalSize / data.range.length));
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- _self.$refs.loading.hide();
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
- },
- });
- },
- /**
- * 复杂数据查询
- * @author YangZhiJie 20210909
- */
- queryInfoWindowDataComplex: function () {
- var _self = this;
- var infoQueryParam = this.$refs.docGeneratorGrid.getQueryParam();
- infoQueryParam.infoFilterFieldValues = _self.$refs.queryCondition.getQueryCondition();
- _self.$refs.loading.show();
- $.ajax({
- url: Common.getApiURL('InfoWindowResource/queryInfoWindowDataComplex'),
- type: 'post',
- dataType: 'json',
- beforeSend: function (request) {
- Common.addTokenToRequest(request);
- },
- contentType: 'application/json',
- data: JSON.stringify(infoQueryParam),
- success: function (data) {
- _self.$refs.loading.hide();
- console.log(data);
- if (data != undefined && data.range != undefined) {
- _self.infoWindowData = data.dataList;
- _self.$refs.docGeneratorGrid.setPagination(data.totalSize, Math.ceil(data.totalSize / data.range.length));
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- _self.$refs.loading.hide();
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
- },
- });
- },
- /**
- * 选择的内容发生了改变
- * @author YangZhiJie 20210909
- */
- selectChanged: function(selectDatas){
- this.$refs.docGeneratorSelected.parseDataList(selectDatas);
- },
- /**
- * 根据id判断数据是否被选中
- * 供外部接口调用
- * @author YangZhiJie 20210909
- */
- isSelectedById: function(id){
- return this.$refs.docGeneratorSelected.isSelectedById(id);
- },
- /**
- * 获取选中的数据
- * 供外部接口调用
- * @author YangZhiJie 20210909
- */
- getSelectedData: function(){
- return this.$refs.docGeneratorSelected.getSelectedData();
- },
- },
- };
- </script>
- <style scoped>
- .grid-container-2 {
- display: grid;
- grid-template-columns: 100%;
- grid-template-rows: min-content auto;
- width: 100%;
- height: calc(100% - 10px);
- }
- .grid-header-2 {
- grid-row: 1 / 2;
- grid-column: 1 / 2;
- }
- .grid-content-2 {
- grid-row: 2 / 3;
- grid-column: 1 / 2;
- overflow: auto;
- }
- </style>
- <style scoped>
- /** 修复分页的样式 By YangZhiJie 2021-07-06 11:23 */
- nav >>> ul.pagination {
- margin: 0 !important;
- }
- </style>
|