query-criteria.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div v-if="showOverlay" style="position: fixed;top: 0;left: 0;width: 100vw;height: 100vh;background-color: rgba(0, 0, 0, 0.5);z-index: 999; "></div>
  3. <div class="query-index">
  4. <div data-v-step="1" :style="showOverlay && curStepVal==1?'margin:auto;width:660px;padding:10px; z-index:1000;display:inline-block;height:50px;background:white;':'margin:auto;width: 600px;padding:10px;'" >
  5. <a-space >
  6. <QueryHistoryComplete id="keyName" v-model:value="formState.defaultKeyString" style="width: 500px"></QueryHistoryComplete>
  7. <a-button type="primary" html-type="submit" @click="getQuery">查询</a-button>
  8. <a-button @click="() => {formRef.resetFields();}" >重置</a-button>
  9. </a-space>
  10. </div>
  11. <v-tour name="queryTour" style="z-index: 1000;" :steps="steps" :options="myOptions" :callbacks="myCallbacks"></v-tour>
  12. <a-divider orientation="center" @click="formState.showMoreQuery=!formState.showMoreQuery;" >
  13. <template v-if="!formState.showMoreQuery" >
  14. 更多查询
  15. <DoubleRightOutlined rotate="90" />
  16. </template>
  17. <template v-else>
  18. 收 起
  19. <DoubleLeftOutlined rotate="90"/>
  20. </template>
  21. </a-divider>
  22. <div data-v-step="2" v-show="formState.showMoreQuery"
  23. :style="showOverlay && curStepVal==2?'margin:auto;width:500px;padding:10px 10px 10px 50px; z-index:1000;display:inline-block;height:390px;background:white;':'margin:auto;width: 500px;padding:10px 10px 10px 50px;'" >
  24. <a-divider orientation="left" ><b style="color:#4E61D0">1.输入检索控制条件</b></a-divider>
  25. <a-row :gutter="24">
  26. <a-col :span="24">
  27. <div class="col-title">组织单位:</div>
  28. <a-input v-model:value="formState.org_name_a1" style="width: 400px"></a-input>
  29. </a-col>
  30. <a-col :span="24">
  31. <div class="col-title">作业区/项目部:</div>
  32. <a-input v-model:value="formState.bz_dwmc" style="width: 400px"></a-input>
  33. </a-col>
  34. <a-col :span="24">
  35. <div class="col-title">井名:</div>
  36. <a-input v-model:value="formState.well_common_name" style="width: 400px"></a-input>
  37. </a-col>
  38. <a-col :span="24">
  39. <div class="col-title">地层名称:</div>
  40. <a-input v-model:value="formState.formation_name" style="width: 400px"></a-input>
  41. </a-col>
  42. </a-row>
  43. </div>
  44. <div data-v-step="3" v-show="formState.showMoreQuery"
  45. :style="showOverlay && curStepVal==3?'margin:auto;width:500px;padding:10px; z-index:1000;display:inline-block;min-height:200px;background:white;':'margin:auto;width: 500px;padding:10px;'" >
  46. <a-divider orientation="left"><b style="color:#4E61D0">2.输入检索内容条件</b></a-divider>
  47. <a-row :gutter="24">
  48. <a-col :span="24" class="query-row" v-for="(it,index) in limiters">
  49. <div class="col-title">
  50. <a-select v-model:value="it.relation" :options="operTexts" class="operTexts"></a-select>
  51. </div>
  52. <a-select v-model:value="it.fields" :options="fieldList" class="operTexts"></a-select>
  53. <a-input v-model:value="it.value" style="width: 285px"></a-input>
  54. <img src="~@/assets/images/add.png" @click="addQuery" v-if="index==0"/>
  55. <img src="~@/assets/images/sub.png" @click="onDelete(index)" v-if="index>0"/>
  56. </a-col>
  57. </a-row>
  58. </div>
  59. </div>
  60. </template>
  61. <script lang="ts">
  62. import {defineComponent, ref,reactive, watch,getCurrentInstance} from 'vue';
  63. import {type FormInstance, message, type SelectProps} from "ant-design-vue";
  64. import QueryHistoryComplete from '@/components/basic/querylog/history-complete.vue';
  65. import {show} from "dom7";
  66. export default defineComponent({
  67. name: 'query-criteria',
  68. methods: {show},
  69. components: {QueryHistoryComplete},
  70. props: {
  71. queryObject: Object,
  72. },
  73. emits: [
  74. "query"
  75. ],
  76. setup(props, {emit}) {
  77. console.log(props);
  78. const curTour = ref({});
  79. const steps = reactive([
  80. {
  81. target:'[data-v-step="1"]',
  82. header:{
  83. title:'<div style="height: 0;border-top: 12px solid transparent; border-bottom: 15px solid transparent;' +
  84. 'border-left: 15px solid transparent;border-right: 12px solid #4c8dff;' +
  85. 'position:absolute;right:364px;top:15px;"></div>' +
  86. '<div style="width:365px;color: white;background: #4c8dff;display:inline-block;' +
  87. 'font-size: 15px;border-radius:10px 10px 0 0;padding:5px 20px 0 10px;font-weight:bolder;">' +
  88. '| “一框式”检索<span style="padding-left: 20px;">1/3</span></div>'
  89. },
  90. content:'<div style="display:inline-block;width:365px;font-size:14px;color: white;background: #4c8dff;' +
  91. 'border-radius:0 0 10px 10px;padding:5px 15px 0px 15px;position: absolute;top:55px;">' +
  92. '综合搜索栏,将检索功能浓缩至"一框"中。可直接输入多种类型的' +
  93. '关键词如井号、井名、生产作业名词到检索框中进行搜索;同时支持输入运算符“大于""等于""少于”“不等于”进行检索词的组合运算<br/>' +
  94. '<br/>点击“更多查询"可查看更多检索条件</div>',
  95. params:{
  96. placement:'right'
  97. }
  98. },{
  99. target:'[data-v-step="2"]',
  100. header:{
  101. title:'<div style="height: 0;border-top: 12px solid transparent; border-bottom: 15px solid transparent;' +
  102. 'border-left: 15px solid transparent;border-right: 12px solid #4c8dff;' +
  103. 'position:absolute;right:369px;top:11px;"></div>' +
  104. '<div style="width:370px;color: white;background: #4c8dff;display: inline-block;font-size: 15px;' +
  105. 'border-radius:10px 10px 0 0;padding:5px 20px 0 10px;font-weight:bolder;">' +
  106. '| 检索控制条件<span style="padding-left: 205px;">2/3</span></div>',
  107. },
  108. content:'<div style="display:inline-block;width:370px;height:50px;font-size:14px;color: white;background: #4c8dff;' +
  109. 'border-radius:0 0 10px 10px;padding:5px 15px 0px 15px;position: absolute;top:50px;">' +
  110. '可选择控件条件进行查询范围的缩窄<br/></div>',
  111. params:{
  112. placement:'right'
  113. }
  114. },{
  115. target:'[data-v-step="3"]',
  116. header:{
  117. title:'<div style="height: 0;border-top: 12px solid transparent; border-bottom: 15px solid transparent;' +
  118. 'border-left: 15px solid transparent;border-right: 12px solid #4c8dff;' +
  119. 'position:absolute;right:450px;bottom:11px;"></div>' +
  120. '<div style="color: white;background: #4c8dff;display: inline;font-size: 15px;' +
  121. 'border-radius:10px 10px 0 0;padding:5px 20px 0 10px;font-weight:bolder;' +
  122. 'position:relative;bottom:198px;">' +
  123. '| 多个检索项组合查询<span style="padding-left: 250px;">3/3</span></div>',
  124. },
  125. content:'<div style="color: white;background: #4c8dff;display: inline;width:450px;font-size: 14px;' +
  126. 'border-radius:0 0 10px 10px;position: absolute;bottom:-89px;padding:5px 15px 0px 15px;">' +
  127. '1.首先须在下拉框中选择“井号"或“井名"的类别,输入想搜索的井<br/>' +
  128. '2.再从下拉框中选择其他检索项如“产油量"等,输入该检索项具体<br/>' +
  129. '要查询的值。例如想查看并号为001的产油量等于100的查询结果。<br/>' +
  130. '3.支持自由选择检索项间的逻辑关系:<br/>' +
  131. 'AND(与)、OR(或)、NOT(非)<br/><br/>' +
  132. '举例:<br/>' +
  133. '1) 检索井名包含12和产油量为100的结果<br/>' +
  134. '<span style="padding-left: 20px;">检索式: 井名 12 AND 产油量100</span><br/>' +
  135. '2) 检索井名包含12但不查地形区为益地的结果<br/>' +
  136. '<span style="padding-left: 20px;">检索式: 井名 12 NOT 地形区 盆地</span><br/>' +
  137. '3) 检索井名为12-12或12-44的31<br/>' +
  138. '<span style="padding-left: 20px;">检索式: 井名 12-12 0R 井名 12-44</span></div>',
  139. params:{
  140. placement:'right'
  141. }
  142. }
  143. ]);
  144. const myOptions = reactive({
  145. dialogVisible:false,
  146. useKeyboardNavigation:false,
  147. labels:{
  148. buttonSkip:' 跳过引导 ',
  149. buttonPrevious:' 上一步 ',
  150. buttonNext:'下一步 ',
  151. buttonStop:' 明白了 '
  152. }
  153. });
  154. const curStepVal = ref(1);
  155. const showOverlay = ref<boolean>(false);
  156. const myCallbacks = ref({
  157. onPreviousStep(){
  158. curStepVal.value -= 1;
  159. loadStyle();
  160. },
  161. onNextStep(){
  162. curStepVal.value += 1;
  163. loadStyle();
  164. },onStop:async function(){
  165. curStepVal.value = 1;
  166. showOverlay.value = false;
  167. const $input = document.getElementById('keyName');
  168. $input?.focus();
  169. }
  170. });
  171. const limiters = ref([{
  172. fields: '',
  173. value: '',
  174. opreation: '等于',
  175. relation: 'AND'
  176. }]);
  177. const formState = ref(Object.assign({}, {
  178. page: 1, rows: 10, showMoreQuery: false,
  179. well_common_name: '',
  180. bz_dwmc: '',
  181. formation_name: '',
  182. org_name_a1: '',
  183. defaultField: '',
  184. defaultKeyString: '',
  185. operation: 'AND'
  186. }, props.queryObject?.formState));
  187. watch(
  188. () => props.queryObject,
  189. () => {
  190. if (props.queryObject != null) {
  191. formState.value = Object.assign({}, {
  192. page: 1, rows: 10, showMoreQuery: true,
  193. well_common_name: '',
  194. bz_dwmc: '',
  195. formation_name: '',
  196. org_name_a1: '',
  197. defaultField: '',
  198. defaultKeyString: '',
  199. operation: 'AND'
  200. }, props.queryObject.formState);
  201. limiters.value = props.queryObject.limiters.length > 0 ? props.queryObject.limiters : [{
  202. field: '',
  203. keyString: '',
  204. operation: 'AND'
  205. }];
  206. }
  207. }, {}
  208. );
  209. function loadStyle(){
  210. setTimeout(()=>{
  211. const $divs = document.getElementsByClassName("v-step__buttons");
  212. for(let i=0;i < $divs.length;i++) {
  213. const div = $divs[i];
  214. if(curStepVal.value==3){
  215. div.setAttribute("style","background-color:#4c8dff;color:white;height:30px;width:100%;" +
  216. "position: relative;top:-201px;padding-top:4px;");
  217. }else{
  218. div.setAttribute("style","background-color:#4c8dff;color:white;height:30px;width:100%;" +
  219. "position: relative;top:-1px;padding-top:4px;");
  220. }
  221. }
  222. const $buttons = document.getElementsByClassName("v-step__button");
  223. for(let i=0;i < $buttons.length;i++) {
  224. const button = $buttons[i];
  225. button.setAttribute("style","border:1px solid white;margin:0 10px 0 20px;padding:0 4px 0 4px;border-radius:5px;");
  226. }
  227. },1);
  228. }
  229. const formRef = ref<FormInstance>();
  230. const operTexts = [
  231. {value: 'AND', label: 'AND'},
  232. {value: 'OR', label: 'OR'},
  233. {value: 'NOT', label: 'NOT'}
  234. ] as SelectProps['options'];
  235. const fieldList = [
  236. {value: 'well_id', label: '井号'},
  237. {value: 'well_common_name', label: '井名'},
  238. {value: 'well_purpose', label: '井别'}
  239. ] as SelectProps['options'];
  240. function addQuery() {
  241. limiters.value.push({fields: '', value: '', opreation: '等于', relation: 'AND'});
  242. }
  243. function onDelete(index) {
  244. limiters.value.splice(index, 1);
  245. }
  246. function getQuery() {
  247. if(showOverlay.value){
  248. message.warn('请退出引导状态再进行操作!');
  249. return false;
  250. }
  251. showOverlay.value = false;
  252. //组装查询条件
  253. let queryObject = {
  254. queryList: [] as any,
  255. limiters: [] as any,
  256. formState: Object,
  257. page: 0,
  258. limit: 10
  259. };
  260. //多个值测试,如 组织单位 in 哪些值
  261. queryObject.formState = formState.value;
  262. queryObject.limiters = limiters.value;
  263. console.log(queryObject);
  264. emit('query', queryObject);
  265. }
  266. return {
  267. formState, limiters, operTexts, fieldList, addQuery, onDelete, getQuery, formRef,
  268. steps,myOptions,curTour,curStepVal,showOverlay,loadStyle,myCallbacks
  269. };
  270. },
  271. mounted(){
  272. this.curTour = getCurrentInstance()?.appContext.config.globalProperties.$tours;
  273. if(this.curTour && this.curTour['queryTour'] && this.formState.showMoreQuery){
  274. const localData = localStorage.getItem('queryTourShow');
  275. const curTour = localData?JSON.parse(localData):null;
  276. if(curTour==null||!curTour.ifShowed){
  277. (this.curTour['queryTour'] as any).start();
  278. this.showOverlay = true;
  279. const curLocalData = JSON.stringify({ifShowed:true});
  280. localStorage.setItem('queryTourShow',curLocalData);
  281. }
  282. }
  283. },
  284. beforeMount() {
  285. this.loadStyle();
  286. }
  287. });
  288. </script>
  289. <style lang="less" scoped>
  290. .query-index {
  291. display: flex;
  292. flex-direction: column;
  293. height: 100%;
  294. background-color: white;
  295. overflow: hidden;
  296. position: relative;
  297. }
  298. .leftTriangle{
  299. height: 0;
  300. border-top: 12px solid transparent;
  301. border-bottom: 15px solid transparent;
  302. border-left: 15px solid transparent;
  303. border-right: 12px solid #4c8dff;
  304. }
  305. .tips{
  306. color: white;
  307. background: #4c8dff;
  308. display: inline-block;
  309. font-size: 14px;
  310. border-radius:0 0 10px 10px;
  311. padding:5px 15px 0px 15px;
  312. }
  313. .ant-row {
  314. .ant-col {
  315. margin: 10px 0px;
  316. .col-title {
  317. width: 120px;
  318. text-align: left;
  319. float: left;
  320. }
  321. }
  322. .query-row {
  323. display: flex;
  324. img {
  325. margin-left: 5px;
  326. }
  327. }
  328. }
  329. .operTexts {
  330. width: 80px;
  331. }
  332. </style>