| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <template>
- <view class="scheme">
- <u-list class="listContent">
- <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
- <myCard :item="item" @del="del(index)" @edit="add('edit',item,index)" :index="index+1"
- :columns="columns" :btnList="btnData">
- </myCard>
- </view>
- </u-list>
- <view class="add" @click="add('add')" v-if="type != 'view'">
- <u-icon name="plus" color="#fff"></u-icon>
- </view>
- </view>
- </template>
- <script>
- import myCard from '@/pages/saleManage/components/myCard.vue'
- import {
- getWarehouseOutStock,
- getIdWarehouseList
- } from '@/api/salesServiceManagement/workOrder/index.js';
- import {
- getByCode
- } from '@/api/pda/common.js'
- export default {
- components: {
- myCard
- },
- props: {
- type: {
- type: String,
- default: 'edit'
- },
- itemList: {
- type: Array,
- default: () => []
- },
- pageName: ''
- },
- watch: {
- itemList: {
- handler(newVal) {
- let list = JSON.parse(JSON.stringify(newVal));
- this.tableList = list;
- this.setTabData()
- },
- deep: true,
- immediate: true
- }
- },
- data() {
- return {
- typeIdList: [],
- btnList: [{
- name: '修改',
- apiName: 'edit',
- btnType: 'primary',
- type: '2',
- pageUrl: '',
- judge: [{
- authorities: '',
- }, {
- fn: (row) => {
- return (this.type != 'view' &&
- row.isApply != 1
- );
- }
- }]
- },
- {
- name: '删除',
- apiName: 'del',
- btnType: 'primary',
- type: '2',
- pageUrl: '',
- judge: [{
- authorities: '',
- }, {
- fn: (row) => {
- return (this.type != 'view' &&
- row.isApply != 1
- );
- },
- }]
- },
- ],
- tableList: []
- }
- },
- computed: {
- btnData() {
- if (this.type == 'view') {
- return [];
- }
- return this.btnList;
- },
- columns() {
- return [
- [{
- label: '名称:',
- prop: 'name',
- type: 'title',
- className: 'perce100',
- }],
- [{
- label: '项目:',
- prop: 'typeId',
- formatter: (row) => {
- let typeId = row.typeId;
- return this.typeIdList.find(item => item.value == typeId)?.text
- }
- }],
- [{
- label: '编码:',
- prop: 'code'
- }, ],
- [{
- label: '型号:',
- prop: 'categoryModel'
- }, {
- label: '规格:',
- prop: 'specification',
- }],
- [{
- label: '仓库:',
- prop: 'warehouseName'
- }],
- [{
- label: '库存:',
- prop: 'warehouseNum',
- }, {
- label: '单位:',
- prop: 'measureUnit'
- }],
- [{
- label: '数量:',
- prop: 'totalCount',
- }, {
- label: '单价:',
- prop: 'singlePrice'
- }],
- [{
- label: '合计:',
- prop: 'settlementPrice',
- }],
- [{
- label: '详细内容:',
- prop: 'content'
- }],
- [{
- prop: 'sparePartsApplyApprovalStatus',
- label: '审核状态:',
- isNone: this.pageName != 'workOrder',
- formatter: (row) => {
- if (row.typeId == 2) {
- const reviewStatus = {
- 0: '未提交',
- 1: '审核中',
- 2: '已审核',
- 3: '审核不通过'
- }
- return !row.sparePartsApplyApprovalStatus ?
- '未提交' :
- reviewStatus[row.sparePartsApplyApprovalStatus];
- }
- },
- },
- {
- prop: 'sparePartsApplyApprovalStatus',
- isNone: this.pageName != 'workOrder',
- label: '出库状态:',
- formatter: (row) => {
- if (row.typeId == 2) {
- return row.sparePartsApplyApprovalStatus == 2 ?
- '已出库' :
- '未出库';
- }
- },
- }
- ],
- [{
- label: '操作:',
- prop: 'action',
- type: 'action',
- className: 'perce100',
- }],
- ]
- }
- },
- created() {
- this.getLevelCode('after_sales_project')
- uni.$off('updateInfo');
- uni.$on('updateInfo', (data) => {
- if (data.index || data.index == 0) {
- let index = data.index;
- delete data.index;
- this.$set(this.tableList, index, data);
- return
- }
- this.tableList.push(data);
- })
- },
- onShow() {
- },
- methods: {
- getTotalPrice(){
- return this.tableList.reduce((a,b)=>{
- console.log(b,'b.settlementPrice')
- return a+(Number(b.settlementPrice)||0)
- },0)
- },
- async getLevelCode(code) {
- try {
- const res = await getByCode(code);
- if (res) {
- let list = Object.values(res).map((el) => {
- let k = Object.keys(el)[0];
- let v = Object.values(el)[0];
- return {
- text: v,
- value: k
- };
- });
- this.typeIdList = list;
- }
- } catch (err) {
- }
- },
- add(type, item = {}, index) {
- if (type == 'edit') {
- item.index = index;
- }
- let data = JSON.stringify(item);
- uni.navigateTo({
- url: `/pages/salesServiceManagement/workOrder/components/schemeAdd?obtain=仓库&type=${type}&data=${data}`
- })
- },
- del(index) {
- uni.showModal({
- title: '确认删除',
- content: '确定要删除所选方案数据吗?',
- confirmText: '删除',
- confirmColor: '#FF4D4F',
- success: (res) => {
- if (res.confirm) {
- this.tableList.splice(index, 1)
- } else if (res.cancel) {
- // 用户点击了取消按钮
- console.log('用户取消删除');
- }
- }
- });
- },
- async setTabData() {
- this.tableList.forEach(async (item, index) => {
- if (item.typeId == 2) {
- this.$set(
- this.tableList[index],
- 'warehouseList',
- await getIdWarehouseList({
- categoryId: item.categoryId
- })
- );
- if (item.warehouseId) {
- this.$set(
- this.tableList[index],
- 'warehouseNum',
- await getWarehouseOutStock({
- warehouseId: item.warehouseId,
- code: item.code
- })
- );
- }
- }
- });
- },
- getTabData() {
- return this.tableList || []
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
- .scheme {
- padding: 10rpx 20rpx 84rpx;
- }
- .add {
- width: 96rpx;
- height: 96rpx;
- border-radius: 48rpx;
- background: #3c9cff;
- position: fixed;
- bottom: 100rpx;
- right: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- </style>
|