No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

826 líneas
42 KiB

  1. <template>
  2. <div>
  3. <v-dialog
  4. v-model="progress"
  5. persistent
  6. width="300"
  7. >
  8. <v-card
  9. color="primary"
  10. dark
  11. >
  12. <v-card-text>
  13. 查詢中...
  14. <v-progress-linear
  15. indeterminate
  16. color="white"
  17. class="mb-0"
  18. ></v-progress-linear>
  19. </v-card-text>
  20. </v-card>
  21. </v-dialog>
  22. <v-tabs
  23. v-model='currentTab'
  24. centered
  25. fixed-tabs
  26. background-color='grey lighten-4'
  27. show-arrows
  28. >
  29. <div class="d-flex align-center">
  30. <!--新增資產群駔對話-->
  31. <v-dialog
  32. v-model='dialogNewAssertGroup'
  33. @click:outside='close'
  34. :retain-focus="false"
  35. overlay-opacity="0"
  36. >
  37. <template v-slot:activator='{ on, attrs }'>
  38. <v-btn
  39. v-bind='attrs'
  40. v-on='on'
  41. icon
  42. >
  43. <v-icon>mdi-plus</v-icon>
  44. </v-btn>
  45. </template>
  46. <v-card>
  47. <v-card-title>
  48. <span class='headline font-weight-bold'>新增資產群組</span>
  49. </v-card-title>
  50. <v-card-text>
  51. <v-container>
  52. <v-row>
  53. <v-col
  54. cols='12'
  55. sm='6'
  56. md='4'
  57. class='d-flex'
  58. >
  59. <v-text-field
  60. v-model="insertAssertGroupDescript"
  61. label='群組名稱'
  62. hint='必填'
  63. />
  64. </v-col>
  65. <v-col
  66. cols='12'
  67. sm='6'
  68. md='4'
  69. class='d-flex'
  70. >
  71. <v-text-field
  72. v-model="insertAssertGroupTablename"
  73. label='資料庫表格名稱'
  74. hint='必填'
  75. />
  76. </v-col>
  77. </v-row>
  78. </v-container>
  79. </v-card-text>
  80. <v-card-actions>
  81. <v-spacer></v-spacer>
  82. <v-btn
  83. color='blue darken-1'
  84. text
  85. @click='close'
  86. >
  87. 取消
  88. </v-btn>
  89. <v-btn
  90. color='blue darken-1'
  91. text
  92. @click='insertAssertGroup'
  93. >
  94. 新增
  95. </v-btn>
  96. </v-card-actions>
  97. </v-card>
  98. </v-dialog>
  99. </div>
  100. <v-tab
  101. v-for='(item, index) in assertGroup'
  102. :key='index'
  103. class=' font-weight-bold'
  104. @mouseover="showTabOptionIcon(index)"
  105. @mouseleave="optionIconShow = -1"
  106. >
  107. <v-icon small>{{ item.text }}</v-icon>
  108. <v-spacer></v-spacer>
  109. <!--修改資產群駔對話-->
  110. <v-dialog
  111. :id="index"
  112. v-model='dialogModifyAssertGroupName'
  113. :retain-focus="false"
  114. overlay-opacity="0"
  115. @click:outside='close'
  116. >
  117. <template v-slot:activator='{ on, attrs }'>
  118. <v-btn
  119. v-bind='attrs'
  120. v-on='on'
  121. icon
  122. >
  123. <v-icon v-show="optionIconShow === index" small
  124. @click="modifyAssertGroup = JSON.parse(JSON.stringify(item))">mdi-pencil
  125. </v-icon>
  126. </v-btn>
  127. </template>
  128. <v-card>
  129. <v-card-title>
  130. <span class='headline font-weight-bold'>修改資產群組名稱</span>
  131. </v-card-title>
  132. <v-card-text>
  133. <v-container>
  134. <v-row>
  135. <v-col
  136. cols='12'
  137. sm='6'
  138. md='4'
  139. class='d-flex'
  140. >
  141. <v-text-field
  142. v-model="modifyAssertGroup.text"
  143. label='群組名稱'
  144. hint='必填'
  145. />
  146. </v-col>
  147. </v-row>
  148. </v-container>
  149. </v-card-text>
  150. <v-card-actions>
  151. <v-spacer></v-spacer>
  152. <v-btn
  153. color='blue darken-1'
  154. text
  155. @click='close'
  156. >
  157. 取消
  158. </v-btn>
  159. <v-btn
  160. color='blue darken-1'
  161. text
  162. @click='modifyAssertGroupName'
  163. >
  164. 修改
  165. </v-btn>
  166. </v-card-actions>
  167. </v-card>
  168. </v-dialog>
  169. <v-btn icon>
  170. <v-icon v-show="optionIconShow === index" small @click="deleteAssertGroup(item)">
  171. mdi-delete
  172. </v-icon>
  173. </v-btn>
  174. </v-tab>
  175. <div class="d-flex align-center">
  176. </div>
  177. <v-tabs-items v-model='currentTab'>
  178. <v-tab-item
  179. v-for='(item, index) in assertGroup'
  180. :key='index'
  181. >
  182. <v-data-table
  183. :items='allCols[item.value]'
  184. :headers='headers'
  185. :height="fullHeight*7/9"
  186. fixed-header
  187. :footer-props="{'items-per-page-options': [30, 40, 50, 60]}"
  188. :items-per-page="30"
  189. >
  190. <template v-slot:item.isselect='{ item }'>
  191. {{item.isselect === 'true' ? '選項':'文字'}}
  192. </template>
  193. <template v-slot:item.isrequire='{ item }'>
  194. {{item.isselect === 'true' ? '是':'否'}}
  195. </template>
  196. <template v-slot:item.isexport='{ item }'>
  197. {{item.isselect === 'true' ? '是':'否'}}
  198. </template>
  199. <template v-slot:item.issearch='{ item }'>
  200. {{item.isselect === 'true' ? '是':'否'}}
  201. </template>
  202. <template v-slot:item.actions='{ item }'>
  203. <v-btn
  204. icon
  205. @click='openDialogModifyCol(item)'
  206. >
  207. <v-icon>mdi-pencil</v-icon>
  208. </v-btn>
  209. <v-icon
  210. small
  211. @click='deleteCol(item)'
  212. >
  213. mdi-delete
  214. </v-icon>
  215. </template>
  216. <template v-slot:footer>
  217. <div class='d-flex ma-2'>
  218. <v-spacer/>
  219. <!--新增資產群駔欄位對話-->
  220. <v-dialog
  221. v-model='dialogInsert'
  222. @click:outside='close'
  223. :retain-focus="false"
  224. overlay-opacity="0"
  225. >
  226. <template v-slot:activator='{ on, attrs }'>
  227. <v-btn
  228. v-bind='attrs'
  229. v-on='on'
  230. color='primary'
  231. >
  232. 新增欄位
  233. </v-btn>
  234. </template>
  235. <v-card>
  236. <v-card-title>
  237. <span class='headline font-weight-bold'>新增欄位</span>
  238. </v-card-title>
  239. <v-card-text>
  240. <v-container>
  241. <v-row>
  242. <v-col
  243. v-for='(header, index) in headers'
  244. :key='index'
  245. cols='12'
  246. sm='6'
  247. md='4'
  248. class='d-flex'
  249. >
  250. <!--文字型欄位-->
  251. <v-text-field
  252. v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0 && header.value !== 'descript2'"
  253. :label='header.text'
  254. :value="insertColItem[header.value]"
  255. hint='必填'
  256. v-on:input='oninput(insertColItem, header.value, $event)'
  257. />
  258. <!--選項型欄位-->
  259. <v-select
  260. v-if="header.value === 'isselect' && isBooleanCol.indexOf(header.value) < 0"
  261. :label='header.text' hint='必填'
  262. v-on:input='oninput(insertColItem, header.value, $event)'
  263. :items="selectColItem.isselect"
  264. :item-text="selectColItem.isselect.text"
  265. :item-value="selectColItem.isselect.value"
  266. />
  267. <!--資產類別細項欄位-->
  268. <v-select
  269. v-if="header.value && isBooleanCol.indexOf(header.value) >= 0"
  270. :label='header.text' hint='必填'
  271. v-on:input='oninput(insertColItem, header.value, $event)'
  272. :items="selectColItem.boolean"
  273. :item-text="selectColItem.boolean.text"
  274. :item-value="selectColItem.boolean.value"
  275. />
  276. <v-btn
  277. v-if="header.value === 'isselect' && insertColItem.isselect === 'true'"
  278. @click='dialogInsertSelectItem = true'
  279. >
  280. 編輯選項
  281. </v-btn>
  282. <!--欄位說明欄位-->
  283. <v-textarea v-if="header.text === '欄位說明'"
  284. :label='header.text' hint='必填'
  285. v-on:input='oninput(insertColItem, header.value, $event)'
  286. auto-grow
  287. rows="1" />
  288. </v-col>
  289. </v-row>
  290. </v-container>
  291. </v-card-text>
  292. <v-card-actions>
  293. <v-spacer></v-spacer>
  294. <v-btn
  295. color='blue darken-1'
  296. text
  297. @click='close'
  298. >
  299. 取消
  300. </v-btn>
  301. <v-btn
  302. color='blue darken-1'
  303. text
  304. @click='insertCol(item)'
  305. >
  306. 新增
  307. </v-btn>
  308. </v-card-actions>
  309. </v-card>
  310. </v-dialog>
  311. <!--新增資產群組欄位選項對話-->
  312. <v-dialog
  313. width="40%"
  314. v-model='dialogInsertSelectItem'
  315. @click:outside='closeDialogInsertSelectItem'
  316. :retain-focus="false"
  317. overlay-opacity="0"
  318. >
  319. <v-card>
  320. <v-card-title>
  321. <span class='headline font-weight-bold'>編輯選項</span>
  322. </v-card-title>
  323. <v-card-text>
  324. <v-container>
  325. <v-row>
  326. <v-col cols="11" class="d-flex align-center">
  327. <v-text-field outlined rounded hide-details
  328. v-model="insertSelectItem"/>
  329. <v-btn class="ml-2" @click='pushInsertSelectItem'>新增</v-btn>
  330. </v-col>
  331. </v-row>
  332. <v-card class="mt-2 col-10"
  333. style="border: 1px solid grey;min-height: 500px;border-radius: 10px">
  334. <v-chip
  335. v-for="(insertSelectItem, index) in insertSelectItems"
  336. :key="index"
  337. class="col-12 my-1"
  338. color="secondary"
  339. >
  340. {{insertSelectItem}}
  341. <v-icon small class="ml-4" @click="deleteInsertSelectItem(index)">mdi-close
  342. </v-icon>
  343. </v-chip>
  344. </v-card>
  345. </v-container>
  346. </v-card-text>
  347. <v-card-actions>
  348. <v-spacer></v-spacer>
  349. <v-btn
  350. color='blue darken-1'
  351. text
  352. @click='closeDialogInsertSelectItem'
  353. >
  354. 關閉
  355. </v-btn>
  356. </v-card-actions>
  357. </v-card>
  358. </v-dialog>
  359. </div>
  360. </template>
  361. </v-data-table>
  362. </v-tab-item>
  363. </v-tabs-items>
  364. <!--修改資產群駔欄位對話-->
  365. <v-dialog
  366. v-model='dialogModify'
  367. @click:outside='close'
  368. :retain-focus="false"
  369. overlay-opacity="0"
  370. >
  371. <v-card>
  372. <v-card-title>
  373. <span class='headline font-weight-bold'>修改欄位</span>
  374. </v-card-title>
  375. <v-card-text>
  376. <v-container>
  377. <v-row>
  378. <v-col
  379. v-for='(header, index) in headers'
  380. :key='index'
  381. cols='12'
  382. sm='6'
  383. md='4'
  384. class='d-flex'
  385. >
  386. <!--文字型欄位-->
  387. <v-text-field
  388. v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0 && header.value !== 'descript2'"
  389. :label='header.text'
  390. :value="modifyColItem[header.value]"
  391. hint='必填'
  392. v-on:input='oninput(modifyColItem, header.value, $event)'
  393. />
  394. <!--選項型欄位-->
  395. <v-select
  396. v-if="header.value === 'isselect' && isBooleanCol.indexOf(header.value) < 0"
  397. :label='header.text' hint='必填'
  398. :value="modifyColItem[header.value]"
  399. v-on:input='oninput(modifyColItem, header.value, $event)'
  400. :items="selectColItem.isselect"
  401. :item-text="selectColItem.isselect.text"
  402. :item-value="selectColItem.isselect.value"
  403. />
  404. <!--資產類別細項欄位-->
  405. <v-select
  406. v-if="header.value && isBooleanCol.indexOf(header.value) >= 0"
  407. :label='header.text' hint='必填'
  408. :value="modifyColItem[header.value]"
  409. v-on:input='oninput(modifyColItem, header.value, $event)'
  410. :items="selectColItem.boolean"
  411. :item-text="selectColItem.boolean.text"
  412. :item-value="selectColItem.boolean.value"
  413. />
  414. <!-- <v-btn-->
  415. <!-- v-if="header.value === 'isselect' && modifyColItem.isselect === 'true'"-->
  416. <!-- @click='dialogModifySelectItem = true'-->
  417. <!-- >-->
  418. <!-- 編輯選項-->
  419. <!-- </v-btn>-->
  420. <!--欄位說明欄位-->
  421. <v-textarea v-if="header.text === '欄位說明'"
  422. :label='header.text' hint='必填'
  423. :value="modifyColItem[header.value]"
  424. v-on:input='oninput(modifyColItem, header.value, $event)'
  425. auto-grow
  426. rows="1" />
  427. </v-col>
  428. </v-row>
  429. </v-container>
  430. </v-card-text>
  431. <v-card-actions>
  432. <v-spacer></v-spacer>
  433. <v-btn
  434. color='blue darken-1'
  435. text
  436. @click='close'
  437. >
  438. 取消
  439. </v-btn>
  440. <v-btn
  441. color='blue darken-1'
  442. text
  443. @click='modifyCol'
  444. >
  445. 修改
  446. </v-btn>
  447. </v-card-actions>
  448. </v-card>
  449. </v-dialog>
  450. <!--修改資產群組欄位選項對話-->
  451. <v-dialog
  452. v-model='dialogModifySelectItem'
  453. @click:outside='closeDialogModifySelectItem'
  454. :retain-focus="false"
  455. overlay-opacity="0"
  456. >
  457. <v-card>
  458. <v-card-title>
  459. <span class='headline font-weight-bold'>編輯選項</span>
  460. </v-card-title>
  461. <v-card-text>
  462. <v-container>
  463. <v-row>
  464. <v-col cols="10" class="d-flex align-center">
  465. <v-text-field v-if="modifyColItem.colname === 'type'"
  466. outlined rounded
  467. label="代號"
  468. hint="Ex:H7"
  469. v-model="modifyTypeSelectItem" />
  470. <v-text-field class="col-12" outlined rounded
  471. label="名稱"
  472. hint="Ex:個人電腦"
  473. v-model="modifySelectItem"/>
  474. <v-btn class="ml-2 mb-8" @click='pushModifySelectItem'>新增</v-btn>
  475. </v-col>
  476. </v-row>
  477. <p class="font-italic mb-0 mt-1">拖曳選項以排序</p>
  478. <v-card
  479. class="mt-2 col-10"
  480. min-height="300px"
  481. style="border: 1px solid grey; border-radius: 10px"
  482. >
  483. <draggable v-model="modifySelectItems">
  484. <v-chip v-for="(modifySelectItem, index) in modifySelectItems" :key="index"
  485. color="secondary" class="col-12 my-1" draggable>
  486. {{ modifySelectItem }}
  487. <v-icon small class="ml-4" @click="deleteModifySelectItem(index)">
  488. mdi-close
  489. </v-icon>
  490. </v-chip>
  491. </draggable>
  492. </v-card>
  493. </v-container>
  494. </v-card-text>
  495. <v-card-actions>
  496. <v-spacer></v-spacer>
  497. <v-btn
  498. color='blue darken-1'
  499. text
  500. @click='closeDialogModifySelectItem'
  501. >
  502. 關閉
  503. </v-btn>
  504. </v-card-actions>
  505. </v-card>
  506. </v-dialog>
  507. </v-tabs>
  508. </div>
  509. </template>
  510. <script>
  511. import draggable from 'vuedraggable';
  512. export default {
  513. name: '',
  514. components: {
  515. draggable,
  516. },
  517. data() {
  518. return {
  519. fullHeight: 0,
  520. dialogInsert: false,
  521. dialogModify: false,
  522. dialogNewAssertGroup: false,
  523. progress: false,
  524. // dialogSearch: false,
  525. title: '資訊資產群組',
  526. headers: [
  527. {'text': '', 'value': 'actions', fixed: true, sortable: false},
  528. {'text': '中文名稱', 'value': 'descript'},
  529. {'text': '資料庫欄位名稱', 'value': 'colname'},
  530. // {'text': '型態', 'value': 'type'},
  531. {'text': '文字框或選項', 'value': 'isselect'},
  532. {'text': '順序', 'value': 'index'},
  533. {'text': '必填', 'value': 'isrequire'},
  534. {'text': '欄位說明', 'value': 'descript2'},
  535. // {'text': '可匯出', 'value': 'isexport'},
  536. // {'text': '可搜尋', 'value': 'issearch'},
  537. ],
  538. allCols: [],
  539. insertColItem: {
  540. 'tablename': '',
  541. 'descript': '',
  542. 'colname': '',
  543. 'level': null,
  544. // 'type': '',
  545. 'index': '',
  546. 'isselect': '',
  547. 'issearch': '',
  548. 'isexport': '',
  549. 'isrequire': ''
  550. },
  551. isBooleanCol: ['isexport', 'isrequire', 'issearch'],
  552. selectColItem: {
  553. 'isselect': [{'text': '文字', 'value': 'false'},
  554. {'text': '選項', 'value': 'true'}]
  555. , 'boolean': [{'text': '是', 'value': 'true'},
  556. {'text': '否', 'value': 'false'}]
  557. },
  558. modifyColItem: {},
  559. assertGroup: [],
  560. currentTab: 0,
  561. types: [],
  562. // selectItem: {},
  563. // searchItem: {},
  564. insertAssertGroupDescript: '',
  565. insertAssertGroupTablename: '',
  566. optionIconShow: -1,
  567. dialogModifyAssertGroupName: false,
  568. modifyAssertGroup: {
  569. text: '',
  570. valsue: '',
  571. },
  572. dialogInsertSelectItem: false,
  573. insertSelectItems: [],
  574. insertSelectItem: '',
  575. modifySelectItems: [],
  576. modifySelectItem: '',
  577. dialogModifySelectItem: false,
  578. oldIndex: '',
  579. modifyTypeSelectItem: '',
  580. }
  581. },
  582. async mounted() {
  583. // this.getSelectItem();
  584. this.progress = true;
  585. this.getTabs();
  586. this.getTypes();
  587. this.inventoryItems = [];
  588. this.getCols();
  589. this.fullHeight = window.innerHeight;
  590. console.log(this.fullHeight);
  591. window.onresize = () => {
  592. // this.fullWidth = window.innerWidth;
  593. this.fullHeight = window.innerHeight;
  594. };
  595. },
  596. computed: {},
  597. watch: {
  598. currentTab() {
  599. this.progress = true;
  600. this.getTypes();
  601. this.getCols();
  602. },
  603. dialogModifySelectItem() {
  604. },
  605. modifySelectItems() {
  606. console.log(this.modifySelectItems[0]);
  607. },
  608. dialogInsert() {
  609. this.insertColItem.index = (parseInt(this.allCols[this.assertGroup[this.currentTab].value][this.allCols[this.assertGroup[this.currentTab].value].length - 1].index) + 1).toString();
  610. },
  611. dialogModify() {
  612. if (this.modifyColItem.isselect === 'true') {
  613. this.getModifySelectItems();
  614. }
  615. this.oldIndex = this.modifyColItem.index;
  616. }
  617. },
  618. methods: {
  619. // eslint-disable-next-line no-unused-vars
  620. log() {
  621. // console.log(col);
  622. console.log(this.modifySelectItems);
  623. },
  624. openDialogModifyCol(item) {
  625. this.modifyColItem = JSON.parse(JSON.stringify(item));
  626. this.dialogModify = true;
  627. },
  628. closeDialogInsertSelectItem() {
  629. this.dialogInsertSelectItem = false;
  630. },
  631. getModifySelectItems() {
  632. this.modifySelectItems = [];
  633. this.$axios.get(`/assert/selectItems?tablename=${this.modifyColItem.tablename}&&colname=${this.modifyColItem.colname}`).then((resp) => {
  634. console.log(resp.data.data);
  635. this.modifySelectItems = resp.data.data;
  636. });
  637. },
  638. closeDialogModifySelectItem() {
  639. this.dialogModifySelectItem = false;
  640. // this.modifySelectItems = [];
  641. },
  642. pushInsertSelectItem() {
  643. if (this.insertSelectItems.indexOf(this.insertSelectItem) >= 0 || this.insertSelectItem === '') {
  644. alert('選項不得重複或為空');
  645. } else {
  646. this.insertSelectItems.push(this.insertSelectItem);
  647. this.insertSelectItem = '';
  648. }
  649. },
  650. pushModifySelectItem() {
  651. if (this.modifySelectItems.indexOf(this.modifySelectItem) >= 0 || this.modifySelectItem === '' || this.modifyTypeSelectItem === '') {
  652. alert('選項不得重複或為空');
  653. } else {
  654. if (this.modifyColItem.colname === 'type') {
  655. this.modifySelectItems.push(`${this.modifyTypeSelectItem} ${this.modifySelectItem}`);
  656. this.modifyTypeSelectItem = '';
  657. this.modifySelectItem = '';
  658. } else {
  659. this.modifySelectItems.push(this.modifySelectItem);
  660. this.modifySelectItem = '';
  661. }
  662. }
  663. },
  664. deleteInsertSelectItem(index) {
  665. this.insertSelectItems.splice(index, 1);
  666. },
  667. deleteModifySelectItem(index) {
  668. this.modifySelectItems.splice(index, 1);
  669. },
  670. oninput(item, key, val) {
  671. this.$set(item, key, val);
  672. },
  673. async getTabs() {
  674. await this.$axios.get(`/assert/assertGroups`).then((resp) => {
  675. this.assertGroup = [];
  676. resp.data.data.forEach((item) => {
  677. let header = {'text': null, 'value': null};
  678. header.text = item.descript;
  679. header.value = item.tablename;
  680. this.assertGroup.push(header);
  681. });
  682. // this.assertGroup.push({'text': 'mdi-plus', 'value': ''});
  683. });
  684. },
  685. getTypes() {
  686. const tablename = this.assertGroup[this.currentTab] ? this.assertGroup[this.currentTab].value : 'hardware';
  687. this.$axios.get(`/assert/Types?tablename=${tablename}`).then((resp) => {
  688. this.types = resp.data.data;
  689. });
  690. },
  691. getCols() {
  692. const tablename = this.assertGroup[this.currentTab] ? this.assertGroup[this.currentTab].value : 'hardware';
  693. this.$axios.get(`/assert/allCols?tablename=${tablename}`).then((resp) => {
  694. this.allCols = resp.data.data;
  695. this.progress = false;
  696. });
  697. },
  698. insertCol() {
  699. this.insertColItem.issearch = 'true';
  700. this.insertColItem.isexport = 'true';
  701. let stop;
  702. for (const key in this.insertColItem) {
  703. if (this.insertColItem[key] === '' && key !== 'tablename') {
  704. alert('所有資料不可為空');
  705. stop = true;
  706. return;
  707. }
  708. }
  709. this.allCols[this.assertGroup[this.currentTab].value].forEach((col) => {
  710. if (this.insertColItem.colname === col.colname) {
  711. alert('資料庫欄位名不可重複');
  712. stop = true;
  713. return;
  714. }
  715. });
  716. if (stop === true) return;
  717. this.insertColItem.tablename = this.assertGroup[this.currentTab].value;
  718. this.insertColItem.insertSelectItems = this.insertSelectItems;
  719. this.$axios.post(`/assert/col`, this.insertColItem).then(() => {
  720. this.getCols();
  721. this.close();
  722. this.insertSelectItems = [];
  723. delete this.insertColItem.tablename;
  724. delete this.insertColItem.insertselectItems;
  725. Object.keys(this.insertColItem).forEach((key) => {
  726. this.insertColItem[key] = '';
  727. });
  728. }
  729. );
  730. },
  731. close() {
  732. this.dialogInsert = false;
  733. this.dialogModify = false;
  734. this.dialogNewAssertGroup = false;
  735. this.dialogModifyAssertGroupName = false;
  736. },
  737. isDisabled(key) {
  738. const disabledKey = ['id'];
  739. return disabledKey.indexOf(key) >= 0;
  740. },
  741. isTextField(key) {
  742. return this.select.indexOf(key) < 0;
  743. },
  744. isSelect(key) {
  745. return this.select.indexOf(key) >= 0;
  746. },
  747. isRequire(key) {
  748. return this.required.indexOf(key) >= 0;
  749. },
  750. getSelectItem() {
  751. this.$axios.get(`/selectItem?tablename=${this.tablename}`).then((resp) => {
  752. this.selectItem = resp.data.data;
  753. });
  754. },
  755. modifyCol() {
  756. let stop;
  757. for (const key in this.modifyColItem) {
  758. if (this.modifyColItem[key] === '') {
  759. alert('所有資料不可為空');
  760. stop = true;
  761. return;
  762. }
  763. }
  764. if (stop === true) return;
  765. this.modifyColItem.tablename = this.assertGroup[this.currentTab].value;
  766. this.modifyColItem.modifySelectItems = this.modifySelectItems;
  767. this.modifyColItem.oldIndex = this.oldIndex;
  768. this.$axios.put(`/assert/col`, this.modifyColItem).then(() => {
  769. this.getCols();
  770. this.close();
  771. this.modifySelectItems = [];
  772. delete this.modifyColItem.tablename;
  773. delete this.modifyColItem.modifySelectItems;
  774. delete this.modifyColItem.oldIndex;
  775. Object.keys(this.modifyColItem).forEach((key) => {
  776. this.modifyColItem[key] = '';
  777. });
  778. }
  779. );
  780. },
  781. deleteCol(item) {
  782. let yes = confirm('確定刪除');
  783. if (yes) {
  784. this.$axios.delete(`/assert/deleteCol?tablename=${item.tablename}&&colname=${item.colname}&&index=${item.index}`).then(() => {
  785. this.getCols();
  786. alert('已刪除');
  787. });
  788. }
  789. },
  790. async insertAssertGroup() {
  791. await this.$axios.post(`/assert/assertGroups`, {
  792. assertGroupDescript: this.insertAssertGroupDescript,
  793. assertGroupTablename: this.insertAssertGroupTablename
  794. });
  795. await this.getTabs();
  796. this.close();
  797. },
  798. showTabOptionIcon(index) {
  799. this.optionIconShow = index;
  800. },
  801. async deleteAssertGroup(item) {
  802. let yes = confirm('確認刪除此群組?');
  803. if (yes) {
  804. await this.$axios.delete(`/assert/assertGroups?tablename=${item.value}`).then(() => {
  805. this.getTabs();
  806. alert('已刪除');
  807. });
  808. }
  809. },
  810. async modifyAssertGroupName() {
  811. await this.$axios.put(`/assert/assertGroups?tablename=${this.modifyAssertGroup.value}&&newDescript=${this.modifyAssertGroup.text}`).then(() => {
  812. this.getTabs();
  813. alert('已修改');
  814. this.close();
  815. });
  816. },
  817. }
  818. }
  819. </script>