{"version":3,"file":"GPos.mjs","sources":["../../../../src/comDefault/GPos/GPos.vue"],"sourcesContent":["<template>\r\n  <span>\r\n    <span>\r\n      <a-select\r\n          ref=\"userselect\"\r\n          :mode=\"props.mode\"\r\n          :size=\"size\"\r\n          :open=\"false\"\r\n          :style=\"{ width: props.showButton ? '85%' : '100%' }\"\r\n          v-model:value=\"currentValue\"\r\n          @click=\"showPosPlusModal\"\r\n      >\r\n        <a-select-option v-for=\"item in selectedList\" :value=\"item.positionId\" :key=\"item.positionId\">{{\r\n            item.positionName\r\n          }}</a-select-option>\r\n      </a-select>\r\n      <a-button v-if=\"props.showButton\" @click=\"showPosPlusModal\" :size=\"size\" :style=\"{ width: props.showButton ? '15%' : '0%' }\">\r\n        <template #icon>\r\n          <select-outlined />\r\n        </template>\r\n        <span>选择</span>\r\n      </a-button>\r\n    </span>\r\n    <pos-selector-plus ref=\"posselectorPlus\" :max=\"max\" :min=\"min\" :radioModel=\"radioModel\" @onBack=\"callBack\" />\r\n  </span>\r\n</template>\r\n<script setup name=\"GPos\">\r\nimport { ref, watch, toRaw, onMounted } from 'vue';\r\nimport  PositionApi  from '@/api/sys/positionApi';\r\n// 接收属性\r\nconst props = defineProps({\r\n  mode: { type: String, default: 'combobox' },\r\n  showButton: { type: Boolean, default: true },\r\n  radioModel: { type: Boolean, default: false },\r\n  modelValue: { type: Array, default: () => [] },\r\n  min: { type: Number, default: 1 },\r\n  max: { type: Number, default: 100000 },\r\n  size: { type: String, default: 'small' }\r\n});\r\n\r\nconst currentValue = ref([]);\r\n\r\nconst selectedList = ref([]);\r\n\r\nconst posselectorPlus = ref();\r\n\r\nwatch(\r\n    () => props.modelValue,\r\n    newValue => {\r\n      if (selectedList.value.length == 0) {\r\n        // 获取机构信息\r\n        if (newValue && newValue.length > 0) {\r\n          reload(newValue);\r\n        }\r\n      }\r\n    }\r\n);\r\n\r\nonMounted(() => {\r\n  if (selectedList.value.length == 0) {\r\n    // 获取机构信息\r\n    if (props.modelValue && props.modelValue.length > 0) {\r\n      reload(props.modelValue);\r\n    }\r\n  }\r\n});\r\n\r\nconst reload = async positionIds => {\r\n  const res = await PositionApi.getPositionListByIds({ positionIds: positionIds });\r\n  if (res.data) {\r\n    res.data.forEach(item => {\r\n      currentValue.value.push(item.positionId);\r\n      selectedList.value.push(item);\r\n    });\r\n  }\r\n};\r\n\r\nconst showPosPlusModal = () => {\r\n  posselectorPlus.value.showPosPlusModal(selectedList.value);\r\n};\r\n\r\n/* const removeSelectedItem = record => {\r\n  remove(selectedList.value, item => item.orgId === record.orgId);\r\n  remove(currentValue.value, item => item === record.orgId);\r\n  // 只有ID\r\n  orgselectorPlus.value.delRecord(record);\r\n  emit('update:modelValue', currentValue.value);\r\n  emit(\r\n    'update:label',\r\n    selectedList.value.map(a => a.orgName)\r\n  );\r\n  emit('update:data', selectedList);\r\n}; */\r\n\r\nconst emit = defineEmits(['update:modelValue', 'update:data', 'update:label', 'change']);\r\n\r\n/**\r\n * 确定\r\n * @param {*} record\r\n */\r\nconst callBack = records => {\r\n  console.log('records', records);\r\n  selectedList.value = [];\r\n  currentValue.value = [];\r\n  for (let index = 0; index < records.length; index++) {\r\n    const element = {\r\n      positionId: records[index].id,\r\n      positionName: records[index].name\r\n    };\r\n    selectedList.value.push(element);\r\n    // 只有ID\r\n    currentValue.value.push(records[index].id);\r\n  }\r\n  console.log('currentValue.value', toRaw(currentValue.value));\r\n  emit('update:modelValue', toRaw(currentValue.value));\r\n  const label = selectedList.value.map(a => a.positionName);\r\n  emit('update:label', label);\r\n  emit('update:data', selectedList);\r\n  emit('change', toRaw(currentValue.value));\r\n};\r\n\r\ndefineExpose({});\r\n</script>\r\n<style lang=\"less\" scoped>\r\n.add-user-wrapper {\r\n  display: flex;\r\n  flex-wrap: wrap;\r\n  min-height: 40px;\r\n  padding-left: 5px;\r\n  .add-user-icon {\r\n    display: flex;\r\n    align-items: center;\r\n    width: 40px;\r\n    height: 32px;\r\n    border-radius: 100px;\r\n    border: 1px solid #3370ff;\r\n    justify-content: center;\r\n    margin-right: 8px;\r\n    margin-top: 8px;\r\n    cursor: pointer;\r\n  }\r\n  .add-user-item {\r\n    display: flex;\r\n    align-items: center;\r\n    min-width: 70px;\r\n    max-width: 50%;\r\n    height: 32px;\r\n    background: #eff0f1;\r\n    border-radius: 16px;\r\n    padding: 0 4px;\r\n    margin-right: 8px;\r\n    margin-top: 8px;\r\n\r\n    img {\r\n      width: 24px;\r\n      height: 24px;\r\n      border-radius: 12px;\r\n    }\r\n    div {\r\n      padding: 0;\r\n      margin: 0 4px;\r\n      min-width: 28px;\r\n      overflow: hidden;\r\n      text-overflow: ellipsis;\r\n      white-space: nowrap;\r\n    }\r\n    i {\r\n      margin-right: 10px;\r\n      color: #646a73;\r\n      cursor: pointer;\r\n    }\r\n  }\r\n}\r\n.selected-items {\r\n  overflow-y: auto;\r\n  margin: 0 10px 0;\r\n  border: 1px dashed #ccc;\r\n  padding: 4px 4px 0;\r\n  min-height: 34px;\r\n  max-height: 60px;\r\n  .ant-tag {\r\n    margin-bottom: 4px;\r\n  }\r\n}\r\n</style>\r\n"],"names":["PositionApi","_createElementBlock","_createElementVNode","_createVNode","_normalizeStyle","_Fragment","_renderList","_createBlock","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,UAAM,QAAQ;AAUd,UAAM,eAAe,IAAI,CAAA,CAAE;AAE3B,UAAM,eAAe,IAAI,CAAA,CAAE;AAE3B,UAAM,kBAAkB,IAAG;AAE3B;AAAA,MACI,MAAM,MAAM;AAAA,MACZ,cAAY;AACV,YAAI,aAAa,MAAM,UAAU,GAAG;AAElC,cAAI,YAAY,SAAS,SAAS,GAAG;AACnC,mBAAO,QAAQ;AAAA,UAChB;AAAA,QACF;AAAA,MACF;AAAA,IACL;AAEA,cAAU,MAAM;AACd,UAAI,aAAa,MAAM,UAAU,GAAG;AAElC,YAAI,MAAM,cAAc,MAAM,WAAW,SAAS,GAAG;AACnD,iBAAO,MAAM,UAAU;AAAA,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