123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <div class="bg" id="index">
- <div class="row1">
- <div class="right">
- <el-button type="primary" size="small" @click="add" class="add">添加</el-button>
- </div>
- </div>
- <el-table ref="singleTable" :data="goodsList" highlight-current-row style="width: 100%;" class="table">
- <el-table-column type="index" width="50" label="序号">
- </el-table-column>
- <el-table-column property="goodsName" label="货名" width="200">
- </el-table-column>
- <el-table-column property="storage" label="剩余库存(吨)" width="200">
- </el-table-column>
- <el-table-column property="setDefault" label="默认货名" width="200">
- <template scope="scope">
- <!-- <el-checkbox v-hasPermission="`speedEdition.goodsNameJsb.default` " v-model="scope.row.checked" @change="change($event,scope.row)">设为默认</el-checkbox> -->
- <el-checkbox v-model="scope.row.checked" @change="change($event,scope.row)">设为默认</el-checkbox>
- </template>
- </el-table-column>
- <el-table-column prop="address" label="操作" show-overflow-tooltip>
- <template scope="scope">
- <!-- <span style="color: #409EFF;margin-right:5px" @click="edit(scope.row)">编辑</span> -->
- <!-- <span v-hasPermission="`speedEdition.goodsNameJsb.delete` " style="color: red;" @click="del(scope.row)">删除</span> -->
- <span style="color: red;" @click="del(scope.row)">删除</span>
- </template>
- </el-table-column>
- </el-table>
- <el-dialog width="320px" :title="goodsNameTitle" :visible.sync="show" :append-to-body="true" :close="inventoryClose">
- <el-form class="goodsName" label-position="right" label-width="80px">
- <el-form-item class="customer-item" label="货名">
- <el-input placeholder="请输入货名" maxlength="100" size="small" v-model="dataObj.goodsName" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="goodsNameConfirm" type='primary'>确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
-
- <script>
- import {
- speedGoodsList,
- speedGoodsAdd,
- speedGoodsEdit,
- speedGoodsDel
- } from '@/model/speedGoods'
- import { floralwhite } from 'color-name';
- export default {
- components: {
- },
- data() {
- return {
- goodsNameTitle: '新增',
- dataObj: {
- compId: localStorage.getItem('ws-pf_compId'),
- goodsName: ''
- },
- deptCircularPage: {},
- deptBudgetTotal: 0,
- currentPage: 1,
- pageSize: 10,
- show: false,
- checked: true,
- goodsList: [],
- };
- },
- filters: {
- numsFilter(msg) {
- return msg || 0;
- },
- },
- created() {
- this.getList()
- },
- mounted() {
- },
- beforeDestroy() {
- },
- methods: {
- change(val1,val2){
- console.log(val1,val2)
- if(val1){
- val2.setDefault=1
- }else{
- val2.setDefault=0
- }
- val2.flag=1
- speedGoodsEdit(val2)
- .toPromise()
- .then((response) => {
- debugger
- if (response == "ok") {
- this.show = false
- this.$message.success('操作成功!')
- this.getList()
- }
- console.log(response)
- })
- },
- getList() {
- speedGoodsList({
- compId: localStorage.getItem('ws-pf_compId')
- })
- .toPromise()
- .then((response) => {
- console.log(response)
- this.goodsList = response
- for(let i = 0;i<this.goodsList.length;i++){
- if(this.goodsList[i].setDefault==0){
- this.goodsList[i].checked = false
- }else{
- this.goodsList[i].checked = true
- }
- }
- })
- },
- inventoryClose() {
- this.show = false
- },
- handleSizeChange(val) {
- console.log(`每页 ${val} 条`)
- this.pageSize = val
- // this.getList()
- },
- handleCurrentChange(val) {
- this.currentPage = val
- console.log(`当前页: ${val}`)
- // this.getList()
- },
- add() {
- this.show = true
- },
- edit(val) {
- console.log(val)
- this.goodsNameTitle = "编辑"
- this.dataObj = val
- this.show = true
- },
- del(val) {
- if(val.storage&&val.storage>0){
- this.$message.error('当前'+val.goodsName+'有剩余库存!')
- return
- }
- this.$confirm('确定删除货名?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- speedGoodsDel({ id: val.id })
- .toPromise()
- .then((response) => {
- debugger
- if (response == "200") {
- this.show = false
- this.$message.success('删除成功!')
- this.getList()
- }
- console.log(response)
- })
- }).catch(() => {
- return false
- });
- },
- goodsNameConfirm() {
- if (this.goodsNameTitle == '新增') {
- speedGoodsAdd(this.dataObj)
- .toPromise()
- .then((response) => {
- debugger
- if (response == "ok") {
- this.$message.success('操作成功!')
- this.show = false
- this.getList()
- }
- console.log(response)
- })
- } else {
- speedGoodsEdit(this.dataObj)
- .toPromise()
- .then((response) => {
- debugger
- if (response == "ok") {
- this.show = false
- this.$message.success('操作成功!')
- this.getList()
- }
- console.log(response)
- })
- }
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .bg {
- width: 100%;
- height: 100%;
- padding: 16px 16px 10px 16px;
- box-sizing: border-box;
- // background-image: url("../../assets/images/pageBg.png");
- background-size: cover;
- background-position: center center;
- }
- .table {
- margin-top: 20px;
- }
- </style>
-
|