index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. <template>
  2. <div class="query-index">
  3. <div class="query-index-tree" v-if="showTree">
  4. <div class="query-index-tree-search">
  5. <a-tabs v-model:activeKey="activeTab" @change="tabChange" style="width:97%;">
  6. <a-tab-pane key="1" tab="组织架构目录">
  7. </a-tab-pane>
  8. <a-tab-pane key="2" tab="地质单元目录" forceRender="true">
  9. </a-tab-pane>
  10. </a-tabs>
  11. <DoubleLeftOutlined @click="showTree=false;colspan=6;"/>
  12. </div>
  13. <div style="margin-top: -15px">
  14. <a-input-search
  15. v-model:value="subjectTrees.searchStr"
  16. placeholder="查找目录..." allow-clear
  17. @search="searchTree"
  18. />
  19. </div>
  20. <div class="query-index-tree-box">
  21. <a-tree
  22. ref="treeRef"
  23. :show-line="true" blockNode="true"
  24. :tree-data="subjectTrees.data"
  25. v-model:expandedKeys="subjectTrees.expandedKeys"
  26. v-model:selectedKeys="subjectTrees.selectedKeys"
  27. :replace-fields="replaceFields"
  28. :autoExpandParent="subjectTrees.autoExpandParent"
  29. @expand="treeOnExpand" @select="treeOnSelect">
  30. <template #switcherIcon="{ switcherCls }">
  31. <caret-down-outlined style="font-size:20px;" :class="switcherCls"/>
  32. </template>
  33. <template #title="{ label,value,children }">
  34. <span v-if="label!=null&&label.indexOf(subjectTrees.searchStr) > -1">
  35. {{ label.substr(0, label.indexOf(subjectTrees.searchStr)) }}
  36. <span style="color: #f50">{{ subjectTrees.searchStr }}</span>
  37. {{ label.substr(label.indexOf(subjectTrees.searchStr) + subjectTrees.searchStr.length) }}
  38. </span>
  39. <span v-else>{{ label }}</span>
  40. </template>
  41. </a-tree>
  42. </div>
  43. </div>
  44. <div class="query-index-close" v-else>
  45. <DoubleRightOutlined @click="showTree=true;colspan=8;"/>
  46. </div>
  47. <div class="query-index-content">
  48. <div class="query-index-form">
  49. <a-form ref="formRef" name="fromQuery"
  50. class="ant-advanced-search-form"
  51. :label-col="labelCol"
  52. :model="formState">
  53. <a-row :gutter="24" class="query-index-row">
  54. <a-col :span="6">
  55. <a-form-item name="well_common_name" label="井名:">
  56. <a-input v-model:value="formState.well_common_name"/>
  57. </a-form-item>
  58. </a-col>
  59. <a-col :span="6">
  60. <a-form-item name="well_type" label="井型:">
  61. <a-tree-select
  62. v-model:value="formState.well_type"
  63. show-search
  64. allow-clear
  65. tree-line
  66. :tree-data="wellTypeTree"
  67. tree-node-filter-prop="label">
  68. </a-tree-select>
  69. </a-form-item>
  70. </a-col>
  71. <a-col :span="6">
  72. <a-form-item name="well_type" label="井别:">
  73. <a-tree-select
  74. v-model:value="formState.well_purpose"
  75. show-search
  76. allow-clear
  77. tree-line
  78. :tree-data="wellPurposeTree"
  79. tree-node-filter-prop="label">
  80. </a-tree-select>
  81. </a-form-item>
  82. </a-col>
  83. <a-col :span="6" style="text-align: left">
  84. <MenuOutlined @click="showQuery=true" v-if="!showQuery"/>
  85. <LineOutlined @click="showQuery=false" v-else/>
  86. <a-button type="primary" html-type="submit" @click="onQuery" style="margin-left: 10px;">查询</a-button>
  87. <a-button html-type="submit"
  88. @click="() => {resetFields();formState.ref_date=new Date(); onQuery()}"
  89. style="margin-left: 10px;">
  90. 重置
  91. </a-button>
  92. </a-col>
  93. </a-row>
  94. <a-row :gutter="24" class="query-index-row" v-if="showQuery">
  95. <a-col :span="18">
  96. <a-form-item name="well_id" label="组织机构:">
  97. <a-tree-select
  98. v-model:value="formState.orgList"
  99. show-search
  100. allow-clear
  101. multiple
  102. tree-line
  103. :tree-data="filterOrgTree(subjectTrees.organizationTree)"
  104. tree-node-filter-prop="label"
  105. @change="onOrgTreeChange"
  106. >
  107. </a-tree-select>
  108. </a-form-item>
  109. </a-col>
  110. </a-row>
  111. <a-row :gutter="24" class="query-index-row" v-if="showQuery">
  112. <a-col :span="18">
  113. <a-form-item name="spud_date_begin" label="地质单元:">
  114. <a-tree-select
  115. v-model:value="formState.unitList"
  116. show-search
  117. allow-clear
  118. multiple
  119. tree-line
  120. :tree-data="filterUnitTree(subjectTrees.constructUnitTree)"
  121. tree-node-filter-prop="label" @change="onUnitTreeChange">
  122. </a-tree-select>
  123. </a-form-item>
  124. </a-col>
  125. </a-row>
  126. <a-row :gutter="24" class="query-index-row" v-if="showQuery">
  127. <a-col :span="6">
  128. <a-form-item name="spud_date_begin" label="开钻日期:">
  129. <a-range-picker :key="formState.ref_date" format="YYYY-MM-DD" :placeholder="['开始日期', '结束日期']"
  130. @change="(d)=>{onRangeChange(d,'spud_date_begin','spud_date_end')}"/>
  131. </a-form-item>
  132. </a-col>
  133. <a-col :span="6">
  134. <a-form-item name="completion_date_begin" label="完井日期:">
  135. <a-range-picker :key="formState.ref_date" format="YYYY-MM-DD" :placeholder="['开始日期', '结束日期']"
  136. @change="(d)=>{onRangeChange(d,'completion_date_begin','completion_date_end')}"/>
  137. </a-form-item>
  138. </a-col>
  139. <a-col :span="6">
  140. <a-form-item name="oil_prod_begin_date_begin" label="投产日期:">
  141. <a-range-picker :key="formState.ref_date" format="YYYY-MM-DD" :placeholder="['开始日期', '结束日期']"
  142. @change="(d)=>{onRangeChange(d,'oil_prod_begin_date_begin','oil_prod_begin_date_end')}"/>
  143. </a-form-item>
  144. </a-col>
  145. </a-row>
  146. <a-row class="edit-operation">
  147. <a-col :span="24" style="text-align: right">
  148. <a-checkbox-group v-model:value="showColumnType" @change="onCheckboxChange">
  149. <a-row>
  150. <a-col :span="8">
  151. <a-checkbox value="oil">显示产油</a-checkbox>
  152. </a-col>
  153. <a-col :span="8">
  154. <a-checkbox value="gas">显示产气</a-checkbox>
  155. </a-col>
  156. <a-col :span="8">
  157. <a-checkbox value="water">显示产水</a-checkbox>
  158. </a-col>
  159. </a-row>
  160. </a-checkbox-group>
  161. <a-radio-group v-model:value="viewModel" style="text-align: left">
  162. <a-radio-button value="list">
  163. <UnorderedListOutlined/>
  164. 列表
  165. </a-radio-button>
  166. <a-radio-button value="card">
  167. <TableOutlined/>
  168. 卡片
  169. </a-radio-button>
  170. </a-radio-group>
  171. </a-col>
  172. </a-row>
  173. </a-form>
  174. </div>
  175. <a-spin :spinning="loading">
  176. <div class="query-index-table" v-if="viewModel=='list'">
  177. <a-table :columns="filterColumns" :data-source="data" :scroll="{ x:'100%', y: 550 }"
  178. :row-key="record=>record.tempId" :pagination="false" @resizeColumn="handleResizeColumn"
  179. bordered>
  180. <template #bodyCell="{ column,record }">
  181. <template v-if="column.dataIndex === 'oil'">
  182. <div style="height:25px">
  183. <ChartCell :timeType="('month')" :dataType="('oil')" :wellId="record.well_id"></ChartCell>
  184. </div>
  185. </template>
  186. <template v-if="column.dataIndex === 'gas'">
  187. <div style="height:25px">
  188. <ChartCell :timeType="('month')" :dataType="('gas')" :wellId="record.well_id"></ChartCell>
  189. </div>
  190. </template>
  191. <template v-if="column.dataIndex === 'water'">
  192. <div style="height:25px">
  193. <ChartCell :timeType="('month')" :dataType="('vol')" :wellId="record.well_id"></ChartCell>
  194. </div>
  195. </template>
  196. <template v-if="column.key === 'well_common_name'">
  197. <a-button type="link" size="small" @click="detail(record.well_id)">{{
  198. record.well_common_name
  199. }}
  200. </a-button>
  201. </template>
  202. <template v-if="column.key === 'operation'">
  203. <a-button type="link" size="small" @click="showDoc(record.well_id)">相关文档</a-button>
  204. </template>
  205. </template>
  206. </a-table>
  207. </div>
  208. <div class="query-index-table" v-else>
  209. <a-row :gutter="[24,8]">
  210. <a-col :span="colspan" v-for="item in data">
  211. <a-card :title="'井名:'+item.well_common_name" class="ant-card-index" bodyStyle="padding: 10px;">
  212. <template #extra>
  213. <a-button type="link" @click="detail(item.well_id)">查看详情</a-button>
  214. <a-button type="link" @click="showDoc(item.well_id)">相关文档</a-button>
  215. </template>
  216. <table class="well-card-table">
  217. <tr>
  218. <th>井型:</th>
  219. <td>{{ item.well_type }}</td>
  220. <th>状态:</th>
  221. <td>{{ item.current_state_name }}</td>
  222. </tr>
  223. <tr>
  224. <th>开钻日期:</th>
  225. <td>{{ item.spud_date }}</td>
  226. <th>含水率:</th>
  227. <td><span style="padding:2px 10px;" :class="getTdColor( item.water_cut)">{{ item.water_cut }}</span>
  228. </td>
  229. </tr>
  230. <tr>
  231. <th>开始采油日期:</th>
  232. <td>{{ item.oil_prod_begin_date }}</td>
  233. <th>最近采油日期:</th>
  234. <td>{{ item.oil_prod_recent_date }}</td>
  235. </tr>
  236. <tr v-if="showColumnType.includes('oil')">
  237. <th>最近月产油量:</th>
  238. <td>
  239. {{ item.oil_prod_mon == null ? "" : (numberToCurrencyNo(item.oil_prod_mon) + "t") }}
  240. </td>
  241. <td colspan="2" rowspan="2">
  242. <div style="height:25px">
  243. <ChartCell :timeType="('month')" :dataType="('oil')" :wellId="item.well_id"
  244. :lineColor="('#E63038')"></ChartCell>
  245. </div>
  246. </td>
  247. </tr>
  248. <tr v-if="showColumnType.includes('oil')">
  249. <th>累产油量:</th>
  250. <td>
  251. {{ item.oil_prod_year == null ? "" : (numberToCurrencyNo(item.oil_prod_year) + "t") }}
  252. </td>
  253. </tr>
  254. <tr v-if="showColumnType.includes('gas')">
  255. <th>最近月产气量:</th>
  256. <td>
  257. {{ item.gas_prod_mon == null ? "" : (numberToCurrencyNo(item.gas_prod_mon) + "m³") }}
  258. </td>
  259. <td colspan="2" rowspan="2">
  260. <div style="height:25px">
  261. <ChartCell :timeType="('month')" :dataType="('gas')" :wellId="item.well_id"></ChartCell>
  262. </div>
  263. </td>
  264. </tr>
  265. <tr v-if="showColumnType.includes('gas')">
  266. <th>累产气量:</th>
  267. <td>
  268. {{ item.gas_prod_year == null ? "" : (numberToCurrencyNo(item.gas_prod_year) + "m³") }}
  269. </td>
  270. </tr>
  271. <tr v-if="showColumnType.includes('water')">
  272. <th>最近注水量:</th>
  273. <td>
  274. {{ item.water_prod_mon == null ? "" : (numberToCurrencyNo(item.water_prod_mon) + "t") }}
  275. </td>
  276. <td colspan="2" rowspan="2">
  277. <div style="height:25px">
  278. <ChartCell :timeType="('month')" :dataType="('vol')" :wellId="item.well_id"></ChartCell>
  279. </div>
  280. </td>
  281. </tr>
  282. <tr v-if="showColumnType.includes('water')">
  283. <th>累注水量:</th>
  284. <td>
  285. {{ item.water_prod_year == null ? "" : (numberToCurrencyNo(item.water_prod_year) + "10kt") }}
  286. </td>
  287. </tr>
  288. </table>
  289. </a-card>
  290. </a-col>
  291. </a-row>
  292. </div>
  293. <a-pagination :page-size-options="pagination.pageSizeOptions" show-size-changer
  294. v-model:current="pagination.current" :total="pagination.total"
  295. style="float: right;margin-top: 10px;"
  296. :pageSize="pagination.pageSize" :show-total="total => `共 ${total} 条`"
  297. @change="(current)=>handleTableChange({ current: current,pageSize: pagination.pageSize })"
  298. @showSizeChange="(current,pageSize)=>handleTableChange({ current: current,pageSize: pageSize })"/>
  299. </a-spin>
  300. <div style="width:100%;height: 500px;margin-top:15px">
  301. <ChartMap :datas="data" :isSearch="(true)"></ChartMap>
  302. </div>
  303. </div>
  304. <a-modal v-model:visible="isShowDoc" title="相关文档" :footer="null" @onCancel="isShowDoc=false">
  305. <a-input-search
  306. v-model:value="fileOptions.docKey"
  307. placeholder="查找文档" allow-clear
  308. />
  309. <div class="files-type">
  310. <a-checkable-tag color="processing"
  311. :checked="fileOptions.selectBusinessType.length==0||fileOptions.selectBusinessType.length==fileOptions.businessType.length"
  312. @change="() => fileOptions.selectBusinessType=[]">全部
  313. </a-checkable-tag>
  314. <template v-for="tag in fileOptions.businessType">
  315. <a-checkable-tag color="processing"
  316. :checked="fileOptions.selectBusinessType.includes(tag)"
  317. @change="checked => onBusTypeChange(checked,tag)">{{ tag }}
  318. </a-checkable-tag>
  319. </template>
  320. </div>
  321. <div style="max-height:300px;overflow-y:scroll;margin-top:10px;">
  322. <a-list item-layout="horizontal" :data-source="docList">
  323. <template #renderItem="{ item }">
  324. <a-list-item v-if="(item.file_name.indexOf(fileOptions.docKey)>-1||fileOptions.docKey=='')
  325. &&(fileOptions.selectBusinessType.length==0||fileOptions.selectBusinessType.includes(item.file_business_type))">
  326. <template #actions>
  327. <filePreview :fileName="item.file_name" :filePath="item.storage_path"></filePreview>
  328. <a-button type="link" @click="downFile(item)" functioncode="T010501" danger>下载</a-button>
  329. </template>
  330. <a-list-item-meta
  331. :description="item.file_business_type">
  332. <template #title>
  333. {{ item.file_name }}
  334. </template>
  335. <template #avatar>
  336. <img src="~@/assets/images/file.png"/>
  337. </template>
  338. </a-list-item-meta>
  339. </a-list-item>
  340. </template>
  341. </a-list>
  342. </div>
  343. </a-modal>
  344. </div>
  345. </template>
  346. <script lang="ts">
  347. import {ref, defineComponent, computed, watch, reactive} from 'vue';
  348. import type {FormInstance} from 'ant-design-vue';
  349. import {useRoute} from 'vue-router';
  350. import {get, postData} from "@/api/common";
  351. import {getPaginationTotalTitle} from "@/utils/common";
  352. import {message} from 'ant-design-vue';
  353. import type {TableProps} from "ant-design-vue";
  354. import {useTabsViewStore} from "@/store/modules/tabsView";
  355. import ChartCell from '@/components/basic/chart/chart-cell.vue'
  356. import ChartMap from '@/components/basic/chart/chart-map.vue'
  357. import {download} from "@/utils/downloadFile";
  358. import {columns, filterColumns, formState, getTdColor} from './table'
  359. import filePreview from '@/components/basic/file-preview/index.vue'
  360. import {numberToCurrencyNo} from "@/utils/common";
  361. export default defineComponent({
  362. name: 'wellinfoindex',
  363. components: {ChartCell, ChartMap, filePreview},
  364. setup() {
  365. const route = useRoute();
  366. const expand = ref(false);
  367. const formRef = ref<FormInstance>();
  368. const loading = ref(false);
  369. const showQuery = ref(false);
  370. const selectedRowKeys = ref([]);
  371. const activeTab = ref("1");
  372. const colspan = ref(8);
  373. const showTree = ref(true);
  374. const isShowDoc = ref(false);
  375. const showColumnType = ref(['oil', 'gas', 'water']);
  376. const data = ref([{children: [], label: '', value: ''}]);
  377. const viewModel = ref("list");
  378. const tabsViewStore = useTabsViewStore();
  379. const docKey = ref('');
  380. const docList = ref<any>([]);
  381. const wellTypeList = ref([{label: "直井", value: "直井"}, {label: "定向井", value: "定向井"}, {label: "分支井", value: "分支井"}]);
  382. const wellPurposeList = ref([{label: "探井", value: "探井"}, {label: "开发井", value: "开发井"}, {label: "水井", value: "水井"}]);
  383. const replaceFields = {
  384. children: 'children',
  385. title: 'label',
  386. key: 'value',
  387. };
  388. const fileOptions = reactive({
  389. docKey: '',
  390. businessType: [] as any[],
  391. selectBusinessType: [] as any[]
  392. })
  393. const wellPurposeTree = ref([]);
  394. get('wellInfo/getWellPurposeTree', {}).then(data => {
  395. wellPurposeTree.value = data;
  396. });
  397. const wellTypeTree = ref([]);
  398. get('wellInfo/getWellTypeTree', {}).then(data => {
  399. wellTypeTree.value = data;
  400. });
  401. function onBusTypeChange(checked, it) {
  402. if (checked) {
  403. fileOptions.selectBusinessType.push(it);
  404. } else {
  405. fileOptions.selectBusinessType.splice(fileOptions.selectBusinessType.indexOf(it), 1);
  406. }
  407. console.log(checked, it);
  408. }
  409. const downFile = (record: any) => {
  410. download(record.storage_path, record.file_name);
  411. };
  412. const resetFields = function () {
  413. let keys: string[] = Object.keys(formState);
  414. keys.forEach(key => {
  415. if (typeof (formState[key]) == "string") {
  416. formState[key] = '';
  417. } else if (typeof (formState[key]) == "object") {
  418. formState[key] = [];
  419. }
  420. })
  421. }
  422. filterColumns.value = [...columns];
  423. function showColumnTypeChange() {
  424. const filterValue = columns.filter((item: any) => {
  425. if (!showColumnType.value.includes("oil")) {
  426. if (["oil_prod_mon", "oil_prod_year", "oil"].includes(item.dataIndex)) {
  427. return false
  428. }
  429. }
  430. if (!showColumnType.value.includes("gas")) {
  431. if (["gas_prod_mon", "gas_prod_year", "gas"].includes(item.dataIndex)) {
  432. return false
  433. }
  434. }
  435. if (!showColumnType.value.includes("water")) {
  436. if (["water_prod_mon", "water_prod_year", "water"].includes(item.dataIndex)) {
  437. return false
  438. }
  439. }
  440. return true
  441. })
  442. //拖拽后在显示隐藏列则需要按拖拽后的列排序
  443. const sortedArray = filterValue.sort((a, b) => {
  444. const indexA = filterColumns.value.findIndex(f => f.key == a.key);
  445. const indexB = filterColumns.value.findIndex(f => f.key == b.key);
  446. return (indexA == -1 || indexB == -1) ? 1 : indexA - indexB;
  447. });
  448. filterColumns.value = [...sortedArray];
  449. setSettingColumns();
  450. }
  451. function getSettingColumns() {
  452. let userColumnsJson = localStorage.getItem('userColumns');
  453. let userShowColumnsType = localStorage.getItem('userShowColumnsType');
  454. if (userColumnsJson != undefined) {
  455. let array = new Array();
  456. let userColumns = JSON.parse(userColumnsJson);
  457. userColumns.forEach(it => {
  458. array.push(columns.find(c => c.key == it.key));
  459. })
  460. filterColumns.value = array;
  461. }
  462. if (userShowColumnsType != undefined) {
  463. showColumnType.value = JSON.parse(userShowColumnsType);
  464. }
  465. }
  466. function setSettingColumns() {
  467. localStorage.setItem("userShowColumnsType", JSON.stringify(showColumnType.value));
  468. localStorage.setItem("userColumns", JSON.stringify(filterColumns.value));
  469. }
  470. const preCheckValues = ref(Object.assign(showColumnType.value));
  471. const onCheckboxChange = (checkValues: []) => {
  472. showColumnTypeChange();
  473. setTimeout(() => {
  474. let tbody = document.getElementsByClassName("ant-table-body")[0];
  475. if (tbody) {
  476. tbody.scrollLeft = preCheckValues.value.length > checkValues.length ? 0 : tbody.scrollWidth;
  477. }
  478. preCheckValues.value = checkValues;
  479. }, 300)
  480. }
  481. const onSelectChange = (keys: any) => {
  482. selectedRowKeys.value = keys;
  483. };
  484. const pagination = computed(() => ({
  485. total: formState.total,
  486. current: formState.page,
  487. pageSize: formState.rows,
  488. showSizeChanger: true,
  489. pageSizeOptions: viewModel.value == "list" ? ['10', '20', '30', '40', '50'] : ['12', '24', '36', '48', '60'],
  490. showTotal: total => getPaginationTotalTitle(total)
  491. }));
  492. watch(() => viewModel.value,
  493. () => {
  494. pagination.value.current = 1;
  495. formState.page = 1;
  496. if (viewModel.value == "list") {
  497. formState.rows = 10;
  498. pagination.value.pageSize = 10;
  499. } else {
  500. formState.rows = 12;
  501. pagination.value.pageSize = 12;
  502. }
  503. loadData();
  504. });
  505. const loadData = async function () {
  506. loading.value = true;
  507. const result: any = await postData('wellInfo/getList', formState);
  508. data.value = result.list;
  509. formState.total = result.total;
  510. loading.value = false;
  511. }
  512. const handleTableChange: TableProps['onChange'] = (
  513. pag: { pageSize: number; current: number },
  514. ) => {
  515. formState.page = pag.current;
  516. formState.rows = pag.pageSize;
  517. loadData();
  518. };
  519. const onRangeChange = (dateString, begin, end) => {
  520. formState[begin] = dateString ? dateString[0].format("YYYY-MM-DD") : '';
  521. formState[end] = dateString ? dateString[1].format("YYYY-MM-DD") : '';
  522. };
  523. const tabChange = (key) => {
  524. console.log("tabChange", key);
  525. if (key == "2") {
  526. formState.org_id_a1 = '';
  527. subjectTrees.value.data = Object.assign(subjectTrees.value.constructUnitTree);
  528. } else {
  529. formState.project_id = ''
  530. subjectTrees.value.data = Object.assign(subjectTrees.value.organizationTree);
  531. }
  532. loadData();
  533. getSubjectTree();
  534. }
  535. const detail = (well_id) => {
  536. tabsViewStore.addTabByPath('/wellinfo/detail', {id: well_id});
  537. }
  538. const onQuery = () => {
  539. loadData();
  540. }
  541. const treeRef = ref();
  542. const subjectTrees = ref({
  543. data: [],
  544. organizationTree: [],
  545. constructUnitTree: [],
  546. expandedKeys: [''],
  547. selectedKeys: [''],
  548. autoExpandParent: true,
  549. searchStr: ''
  550. });
  551. const getSubjectData = async function () {
  552. get('wellInfo/getOrganizationTree', {tabName: subjectTrees.value.searchStr}).then(data => {
  553. subjectTrees.value.organizationTree = data;
  554. subjectTrees.value.data = Object.assign(data);
  555. getSubjectTree();
  556. });
  557. get('wellInfo/getConstructUnitTree', {tabName: subjectTrees.value.searchStr}).then(data => {
  558. subjectTrees.value.constructUnitTree = data;
  559. });
  560. }
  561. const getSubjectTree = async function () {
  562. //计算第一个展开节点
  563. subjectTrees.value.expandedKeys = [];
  564. if (subjectTrees.value.data && subjectTrees.value.data.length > 0) {
  565. subjectTrees.value.expandedKeys.push((subjectTrees.value.data[0] as any).value + "");
  566. }
  567. generateList(subjectTrees.value.data);
  568. }
  569. getSubjectData();
  570. const searchTree = () => {
  571. if (subjectTrees.value.searchStr == "") {
  572. return;
  573. }
  574. const expanded = dataList
  575. .map((item: any) => {
  576. if (item.label != null && item.label.indexOf(subjectTrees.value.searchStr) > -1) {
  577. return getParentKey(item.value as string, subjectTrees.value.data);
  578. }
  579. return null;
  580. })
  581. .filter((item, i, self) => item && self.indexOf(item) === i);
  582. if (expanded.length == 0) {
  583. message.warning('没有查询到相关目录');
  584. }
  585. subjectTrees.value.expandedKeys = expanded as string[];
  586. subjectTrees.value.autoExpandParent = true;
  587. // (treeRef.value as any).scrollTo({key:expanded[0]});
  588. }
  589. const dataList: any[] = [];
  590. const generateList = (data: any[]) => {
  591. for (let i = 0; i < data.length; i++) {
  592. const node = data[i];
  593. const label = node.label;
  594. dataList.push({value: node.value, label: label as string});
  595. if (node.children) {
  596. generateList(node.children);
  597. }
  598. }
  599. };
  600. const getParentKey = (key: string, tree: any[]): string | number | undefined => {
  601. let parentKey;
  602. for (let i = 0; i < tree.length; i++) {
  603. const node = tree[i];
  604. if (node.children) {
  605. if (node.children.some(item => item.value === key)) {
  606. parentKey = node.value;
  607. } else if (getParentKey(key, node.children)) {
  608. parentKey = getParentKey(key, node.children);
  609. }
  610. }
  611. }
  612. return parentKey;
  613. };
  614. const treeOnExpand = function (keys: string[]) {
  615. subjectTrees.value.expandedKeys = keys;
  616. subjectTrees.value.autoExpandParent = false;
  617. }
  618. const treeOnSelect = function (selected, selectedNodes, node) {
  619. console.log(selected, selectedNodes, node);
  620. if (selectedNodes.node.parent != undefined || activeTab.value == "1") {
  621. if (activeTab.value == "1") {
  622. formState.org_id_a1 = selected.length > 0 ? selectedNodes.node.key : '';
  623. formState.orgList = selected.length > 0 ? [formState.org_id_a1] : [];
  624. } else {
  625. formState.project_id = selected.length > 0 ? selectedNodes.node.key : '';
  626. formState.unitList = selected.length > 0 ? [formState.project_id] : [];
  627. }
  628. loadData();
  629. }
  630. }
  631. const orgUnitList: any =ref([]);
  632. const unitOrgList: any =ref([]);
  633. let filterTreeData: any[] = [];
  634. //组织机构和地质单元联动,选择组织机构只显示该组织机构的地质单元
  635. function filterOrgTree(treeData: any[]) {
  636. if(formState.unitList.length==0){
  637. return treeData;
  638. }
  639. filterTreeData = [];
  640. treeData.forEach(node => {
  641. if (unitOrgList.value.indexOf(node.value) > -1) {
  642. filterTreeData.push(node);
  643. return;
  644. }
  645. eachOrgTreeNode(node.children);
  646. })
  647. return filterTreeData;
  648. }
  649. function eachOrgTreeNode(treeData: any[]) {
  650. if (treeData == undefined) {
  651. return;
  652. }
  653. treeData.forEach(node => {
  654. if (unitOrgList.value.indexOf(node.value) > -1) {
  655. filterTreeData.push(node);
  656. return;
  657. }
  658. eachOrgTreeNode(node.children);
  659. })
  660. }
  661. function onOrgTreeChange() {
  662. postData('wellInfo/getOrgProjectList', {orgList: formState.orgList}).then((data: any[]) => {
  663. orgUnitList.value = data.map(x => x.project_id);
  664. })
  665. }
  666. function onUnitTreeChange() {
  667. postData('wellInfo/getOrgProjectList', {unitList: formState.unitList}).then((data: any[]) => {
  668. unitOrgList.value = data.map(x => x.org_id);
  669. })
  670. }
  671. function filterUnitTree(treeData: any[]) {
  672. if(formState.orgList.length==0){
  673. return treeData;
  674. }
  675. filterTreeData = [];
  676. treeData.forEach(node => {
  677. if (orgUnitList.value.indexOf(node.value) > -1) {
  678. filterTreeData.push(node);
  679. return;
  680. }
  681. eachUnitTreeNode(node.children);
  682. })
  683. return filterTreeData;
  684. }
  685. function eachUnitTreeNode(treeData: any[]) {
  686. if (treeData == undefined) {
  687. return;
  688. }
  689. treeData.forEach(node => {
  690. if (orgUnitList.value.indexOf(node.value) > -1) {
  691. filterTreeData.push(node);
  692. return;
  693. }
  694. eachUnitTreeNode(node.children);
  695. })
  696. }
  697. const showDoc = (id) => {
  698. get('wellInfo/getWellDocumentList', {wellId: id}).then(data => {
  699. docList.value = data;
  700. isShowDoc.value = true;
  701. fileOptions.businessType = docList.value.map(x => x.file_business_type);
  702. fileOptions.businessType = Array.from(new Set(fileOptions.businessType));
  703. })
  704. };
  705. const labelCol = {style: {width: '100px'}};
  706. return {
  707. route, selectedRowKeys, loading, activeTab, showTree, onSelectChange, data,
  708. expand, onQuery, loadData, onRangeChange, showQuery, wellTypeList, wellPurposeList, replaceFields,
  709. formRef, viewModel, handleTableChange, detail,
  710. formState, isShowDoc, showDoc, docKey, docList, resetFields, showColumnType, filterColumns, filterUnitTree,filterOrgTree,
  711. labelCol, getTdColor, downFile,
  712. tabChange, onCheckboxChange, treeRef, colspan,
  713. treeOnExpand,
  714. subjectTrees, fileOptions, onBusTypeChange, onOrgTreeChange,onUnitTreeChange,
  715. getSubjectTree, searchTree,
  716. treeOnSelect, pagination, getSettingColumns, wellPurposeTree, wellTypeTree, numberToCurrencyNo,
  717. handleResizeColumn: (w, col) => {
  718. col.width = w;
  719. }
  720. };
  721. },
  722. created() {
  723. this.getSettingColumns();
  724. this.loadData();
  725. }
  726. ,
  727. activated() {
  728. }
  729. });
  730. </script>
  731. <style lang="less">
  732. .query-index {
  733. display: flex;
  734. flex-direction: row;
  735. min-height: 100%;
  736. background-color: white;
  737. }
  738. .query-index-tree {
  739. min-width: 260px;
  740. max-width: 360px;
  741. border-right: 2px solid #f2f2f2;
  742. margin-right: 5px;
  743. }
  744. .query-index-close {
  745. width: 15px;
  746. padding-top: 10px;
  747. padding-left: 10px;
  748. }
  749. .query-index-content {
  750. flex-grow: 1;
  751. display: flex;
  752. flex-direction: column;
  753. width: 80%;
  754. }
  755. .query-index-form {
  756. padding: 15px 10px 10px 15px;
  757. }
  758. .query-index-table {
  759. flex-grow: 1;
  760. display: flex;
  761. .ant-row {
  762. width: 100%;
  763. }
  764. }
  765. .query-index-tabs {
  766. margin-left: 10px;
  767. margin-right: 10px;
  768. height: 100%;
  769. flex: 1;
  770. }
  771. .tabs-view-content {
  772. padding: 0px;
  773. }
  774. .query-index-tree-item {
  775. white-space: nowrap; /*强制span不换行*/
  776. display: inline-block; /*将span当做块级元素对待*/
  777. text-overflow: ellipsis; /*超出部分以点号代替*/
  778. }
  779. .query-index-tree-search {
  780. padding: 5px;
  781. border-bottom: 2px solid #f2f2f2;
  782. display: flex;
  783. align-items: center;
  784. }
  785. .query-index-tree-box {
  786. padding: 5px;
  787. padding-top: 10px;
  788. overflow-y: scroll;
  789. max-height: 1000px;
  790. }
  791. .col-text {
  792. padding-right: 0px !important;
  793. text-align: right;
  794. font-weight: bold;
  795. }
  796. .col-content {
  797. width: 200px;
  798. overflow: hidden;
  799. text-overflow: ellipsis;
  800. white-space: nowrap;
  801. }
  802. .ant-card-body {
  803. padding: 10px;
  804. }
  805. .well-card-table {
  806. width: 100%;
  807. th {
  808. width: 25%;
  809. text-align: left;
  810. font-size: 12px;
  811. }
  812. td {
  813. width: 25%;
  814. text-align: left;
  815. font-size: 12px;
  816. }
  817. }
  818. .ant-card-index {
  819. .ant-card-head-title {
  820. font-weight: bold;
  821. color: #1f37dd;
  822. }
  823. .ant-card-head {
  824. padding: 0px 10px;
  825. height: 35px;
  826. background-color: #F9FCFF;
  827. }
  828. .ant-card-head-wrapper {
  829. height: 35px;
  830. margin-top: 5px;
  831. }
  832. }
  833. .ant-card-index:hover {
  834. box-shadow: 3px 2px 10px #999;
  835. opacity: 0.8;
  836. }
  837. .color_level1, .ant-table-tbody > tr > td.color_level1:hover {
  838. }
  839. .color_level2, .ant-table-tbody > tr > td.color_level2:hover {
  840. background-color: #EAF4FF !important;
  841. }
  842. .color_level3, .ant-table-tbody > tr > td.color_level3:hover {
  843. background-color: #D5EAFF !important;
  844. }
  845. .color_level4, .ant-table-tbody > tr > td.color_level4:hover {
  846. background-color: #B7DBFF !important;
  847. }
  848. .files-type {
  849. margin-top: 10px;
  850. span {
  851. color: #8e9ae1;
  852. border: 1px solid #c6ccf0;
  853. padding: 3px 5px;
  854. margin-bottom: 5px;
  855. }
  856. .ant-tag-checkable-checked, .ant-tag-checkable-checked:active {
  857. background-color: #8e9ae1;
  858. color: #ffffff;
  859. }
  860. }
  861. </style>