|
|
@@ -1,8 +1,11 @@
|
|
|
import Custom from '@/pages/FormVolume/js/custom'
|
|
|
+import { dataTopic, dataResult } from '../js/config'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
attrShow: {
|
|
|
+ panel: true,
|
|
|
+ list: true,
|
|
|
attr: true,
|
|
|
compt: false
|
|
|
}
|
|
|
@@ -17,10 +20,70 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- selectItem(item) {
|
|
|
- this.onTipComptState()
|
|
|
- this.dataItem = item
|
|
|
- this.attrShow.compt = true
|
|
|
+ async addAttrData () {
|
|
|
+ try {
|
|
|
+ let msg1 = '请确认当前问卷已保存,是否新增问卷?'
|
|
|
+ let msg2 = '是否新增问卷?'
|
|
|
+ let msg = this.data ? msg1 : msg2
|
|
|
+ await this.$dialog.confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: msg,
|
|
|
+ })
|
|
|
+ this.selectData(dataTopic())
|
|
|
+ } catch (err) {
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async selectData(data) {
|
|
|
+ try {
|
|
|
+ this.$set(this, 'data', data)
|
|
|
+ let obj = data.result[0]
|
|
|
+ obj && this.selectItem(obj, true)
|
|
|
+ } catch (err) {
|
|
|
+ console.warn(err)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addItem () {
|
|
|
+ try {
|
|
|
+ let result = this.data.result
|
|
|
+ let index = result.length
|
|
|
+ this.dataItem && result.some((item, i) => {
|
|
|
+ if (item === this.dataItem) {
|
|
|
+ index = i + 1
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let data = dataResult()
|
|
|
+ result.splice(index, 0, data)
|
|
|
+ this.dataItem = data
|
|
|
+ } catch (err) {
|
|
|
+ }
|
|
|
+ },
|
|
|
+ removeItem () {
|
|
|
+ try {
|
|
|
+ let result = this.data.result
|
|
|
+ let index = null
|
|
|
+ this.dataItem && result.some((item, i) => {
|
|
|
+ if (item === this.dataItem) {
|
|
|
+ index = i
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (typeof index === 'number') {
|
|
|
+ result.splice(index, 1)
|
|
|
+ this.dataItem = null
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async selectItem(item, b) {
|
|
|
+ try {
|
|
|
+ if (!b) {
|
|
|
+ this.onTipComptState()
|
|
|
+ }
|
|
|
+ this.dataItem = item
|
|
|
+ this.attrShow.compt = true
|
|
|
+ } catch (err) {
|
|
|
+ }
|
|
|
},
|
|
|
onChangeCompType (type) {
|
|
|
let { val } = this.dataItem
|
|
|
@@ -70,23 +133,47 @@ export default {
|
|
|
this.moveItemIndex(1)
|
|
|
}
|
|
|
},
|
|
|
- onTipComptState () {
|
|
|
- let { mgTipComptDirectionState } = this.$store.state.manager
|
|
|
- if (mgTipComptDirectionState) {
|
|
|
- return
|
|
|
+ async onTipComptState () {
|
|
|
+ let pm
|
|
|
+ try {
|
|
|
+ let { mgTipComptDirectionState } = this.$store.state.manager
|
|
|
+ if (mgTipComptDirectionState || !this.data) {
|
|
|
+ pm = Promise.resolve()
|
|
|
+ }
|
|
|
+ if (!pm) {
|
|
|
+ await this.$dialog.confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: '按 ↑ ↓ 可调整位置!',
|
|
|
+ confirmButtonText: '不再提示',
|
|
|
+ })
|
|
|
+ this.$store.commit('setMgTipComptDirectionState', 1)
|
|
|
+ pm = Promise.resolve()
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ pm = Promise.reject()
|
|
|
}
|
|
|
- this.$dialog.confirm({
|
|
|
- title: '提示',
|
|
|
- message: '按 ↑ ↓ 可调整位置!',
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '不再提示',
|
|
|
- confirmButtonColor: '#666',
|
|
|
- cancelButtonColor: '#ee0a24'
|
|
|
- }).then(() => {
|
|
|
-
|
|
|
- }).catch(() => {
|
|
|
- this.$store.commit('setMgTipComptDirectionState', 1)
|
|
|
- })
|
|
|
+ return pm
|
|
|
+ },
|
|
|
+ async onTipAttrState() {
|
|
|
+ let pm
|
|
|
+ try {
|
|
|
+ let { mgTipAttrSaveState } = this.$store.state.manager
|
|
|
+ if (mgTipAttrSaveState || !this.data) {
|
|
|
+ pm = Promise.resolve()
|
|
|
+ }
|
|
|
+ if (!pm) {
|
|
|
+ await this.$dialog.confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: '切换问卷,请确认修改已保存?',
|
|
|
+ confirmButtonText: '不再提示',
|
|
|
+ })
|
|
|
+ this.$store.commit('setMgTipAttrSaveState', 1)
|
|
|
+ pm = Promise.resolve()
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ pm = Promise.reject()
|
|
|
+ }
|
|
|
+ return pm
|
|
|
},
|
|
|
onChangeContent (ev) {
|
|
|
try {
|