github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/witch/webroot/viz-ptr.html (about)

     1  <script type="text/x-template" id="viz-ptr-template">
     2      <div>
     3          <span v-if="data.__ptr__ === '0'">NULL</span>
     4          <el-button v-else-if="!(ptrState[data.__ptr__])"
     5                     @click="showPtr(path, data.__ptr__, $event)"
     6                     icon="el-icon-plus" size="mini">
     7          {{data.__ptr__}}
     8          </el-button>
     9          <el-button v-else
    10                     @click="hidePtr(path, data.__ptr__, $event)"
    11                     icon="el-icon-minus" size="mini">
    12          {{data.__ptr__}}
    13          </el-button>
    14      </div>
    15  </script>
    16  <script>
    17      Vue.component('viz-ptr', {
    18          template: '#viz-ptr-template',
    19          props: ['data','path'],
    20          data: function () {
    21              return {
    22                  ptrState: {}
    23              }
    24          },
    25          methods: {
    26              ptrBtnIcon: function (ptr) {
    27                  if (this.ptrState[ptr]) {
    28                      return 'el-icon-minus';
    29                  }
    30                  return 'el-icon-plus';
    31              },
    32              showPtr: function (path, ptr, event) {
    33                  Vue.set(this.ptrState, ptr, true);
    34                  var sourceElem = event.target.parentElement;
    35                  if (sourceElem.tagName !== 'TD') {
    36                      sourceElem = sourceElem.parentElement;
    37                  }
    38                  if (sourceElem.tagName !== 'TD') {
    39                      sourceElem = sourceElem.parentElement;
    40                  }
    41                  this.$emit('showPtr', {
    42                      connectorId: this.path,
    43                      targetPtr: ptr,
    44                      sourceElem: sourceElem
    45                  });
    46              },
    47              hidePtr: function (path, ptr, event) {
    48                  Vue.set(this.ptrState, ptr, false);
    49                  var sourceElem = event.target.parentElement;
    50                  if (sourceElem.tagName !== 'TD') {
    51                      sourceElem = sourceElem.parentElement;
    52                  }
    53                  if (sourceElem.tagName !== 'TD') {
    54                      sourceElem = sourceElem.parentElement;
    55                  }
    56                  this.$emit('hidePtr', {
    57                      connectorId: this.path,
    58                      targetPtr: ptr,
    59                      sourceElem: sourceElem
    60                  });
    61              }
    62          }
    63      });
    64  </script>