Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <form method="POST" @submit.prevent="onSubmit">
- <br/>
- <div class="alert" :class="{'alert-success': alert_status, 'alert-danger': !alert_status}" role="alert" v-show="message">{{ message }}</div>
- <br/>
- <div class="panel panel-default">
- <div class="panel-heading">Regra de Preço Geral</div>
- <div class="panel-body">
- Essa regra será utilizada sempre quando <b>NÃO HOUVER</b> uma regra por categoria de anúncio configurada.
- <br/><br/>
- <div class="form-group">
- <label>Utilizar tabela de preço</label>
- <select class="form-control" v-model="price_table_code">
- <option>Não</option>
- <option :value="table.code" v-for="table in tables">{{table.code}}</option>
- </select>
- </div>
- </div>
- </div>
- <button class="btn btn-primary pull-right">Salvar</button>
- </form>
- </template>
- <script>
- export default {
- name: 'PriceRules',
- props: [
- "user_id"
- ],
- data () {
- return {
- tables: "",
- price_table_code: "Não",
- message: "",
- alert_status: false
- };
- },
- created() {
- // Futuramente refatorar com async await
- axios.get('/account/rules/price')
- .then( response => this.tables = response.data.body.results )
- .then( axios.get('/account/rules/price/' + this.user_id)
- .then( response => this.price_table_code = "Não" ) )
- .then( axios.get('/account/rules/price/' + this.user_id)
- .then( response =>
- {
- if ( response.data.status !== 'error')
- {
- this.price_table_code = response.data.body
- }
- }
- )
- )
- },
- methods: {
- onSubmit () {
- axios.post('/account/rules/price/' + this.user_id, {
- table_price: this.price_table_code
- }).then(response => {
- if(response.data.status === 'success')
- {
- this.alert_status = true;
- }
- this.message = response.data.message;
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement