whj 1 year ago
parent
commit
2e1911fc0d

+ 47 - 1
src/api/purchase/purchase-order.js

@@ -31,6 +31,36 @@ export function getPurchaseOrderPage2 (parameter) {
     }
   })
 }
+/**
+ * page func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getpurchaseRecord (parameter) {
+  return axios({
+    url: '/longyanpurchaseorder/order/getpurchaseRecord',
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+/**
+ * page func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getPurchaseReport (parameter) {
+  return axios({
+    url: '/longyanpurchaseorder/order/getPurchaseReport?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
 /**
  * add func
  * parameter: { }
@@ -48,7 +78,23 @@ export function addPurchaseOrder (parameter) {
     data: parameter
   })
 }
-
+/**
+ * add func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function addPurchaseOrder2 (parameter) {
+  return axios({
+    url: '/longyanpurchaseorder/order',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}
 /**
  * update func
  * parameter: { }

+ 2 - 1
src/utils/dict.js

@@ -331,7 +331,8 @@ DictCache.TYPE = {
   HIDDEN_DANGER_STATUS: 'HIDDEN_DANGER_STATUS',
   SB_CHANGE_LOG_TYPE: 'SB_CHANGE_LOG_TYPE',
   CHECK_TYPE: 'CHECK_TYPE', // 强检,
-  PROJECT_NEW_AND_OLD: 'PROJECT_NEW_AND_OLD' // 厂区
+  PROJECT_NEW_AND_OLD: 'PROJECT_NEW_AND_OLD', // 厂区
+  LONG_YAN_PURCHASE_TYPE: 'LONG_YAN_PURCHASE_TYPE'
 }
 DictCache.CODE = {
 

+ 5 - 4
src/views/purchase/purchase-order-page/PurchaseOrderPage.vue

@@ -20,7 +20,7 @@
       </div>
 
       <div class="table-operator" style="margin-bottom: 8px;">
-        <!--      <a-button v-if="$auth('purchase-purchase-orders-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
+        <a-button v-if="$auth('purchase-purchase-orders-add')" type="primary" icon="plus" @click="$refs.baseForm.base()">新增</a-button>
         <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-orders-del')">
           <a-menu slot="overlay">
             <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
@@ -50,19 +50,20 @@
         </span>
       </s-table>
     </div>
-    <!--    <purchase-dispatch-order ref="dispatchOrder" @ok="handleOk"/>-->
+    <BaseForm ref="baseForm" @ok="handleOk"/>
   </a-card>
 </template>
 
 <script>
 import { STable, Ellipsis } from '@/components'
 import { getPurchaseOrderPage2, deletePurchaseOrders } from '@/api/purchase/purchase-order'
-
+import BaseForm from './modules/BaseForm.vue'
 export default {
   name: 'PurchaseOrderList',
   components: {
     STable,
-    Ellipsis
+    Ellipsis,
+    BaseForm
   },
   data () {
     return {

+ 162 - 0
src/views/purchase/purchase-order-page/modules/BaseForm.vue

@@ -0,0 +1,162 @@
+<template>
+  <a-modal
+    title="新增"
+    :width="800"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @cancel="handleCancel"
+  >
+    <a-form :form="form">
+      <row-list :col="1" v-show="false">
+        <row-item>
+          <a-form-item>
+            <a-input v-decorator="['id']" type="hidden"/>
+            <a-input v-decorator="['sbId']" type="hidden"/>
+          </a-form-item>
+        </row-item>
+      </row-list>
+      <a-row type="flex">
+        <a-col :sm="20" >
+          <a-form-item
+            label="采购计划名称"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input v-decorator="['name', {rules: [{required: true, message: '采购计划名称不能为空'}]}]" />
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="采购计划类型"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-select v-decorator="['type', { rules: [{required: true, message: '任务等级不能为空'}]}]" placeholder="请选择">
+              <a-select-option
+                v-for="(label,value) in typeMap"
+                :key="value"
+                :label="label"
+                :value="label">{{ label }}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+
+        <a-col :sm="20" >
+          <a-form-item
+            label="设备名称"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              style="width: 70%"
+              disabled
+              v-decorator="['sbName', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
+            <a-button style="width: 30%" type="primary" @click="handleSbSelect">选择</a-button>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="备注"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['remark']"/>
+          </a-form-item>
+        </a-col>
+      </a-row>
+    </a-form>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
+    </template>
+    <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
+
+  </a-modal>
+</template>
+
+<script>
+import { addPurchaseOrder2 } from '@/api/purchase/purchase-order'
+
+import SbInfoSelectModal from './SbInfoSelectModal'
+
+export default {
+  name: 'BaseFillGather',
+  data () {
+    return {
+      form: this.$form.createForm(this),
+      visible: false,
+      typeMap: {},
+      ipqcMap: [],
+      model: {},
+      sbIds: [],
+      rows: [],
+      sortNums: [],
+      directorMap: [],
+      infoNum: 0,
+      confirmLoading: false
+    }
+  },
+  components: {
+    SbInfoSelectModal
+  },
+  created () {
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+    },
+    // 获取巡检人与巡检主管信息
+
+    handleSbSelect () {
+      this.$refs.sbInfoSelectModal.base({})
+    },
+    handleSbSelectd (keys, rows) {
+      const [ key ] = keys
+      const [ row ] = rows
+      const { form: { setFieldsValue } } = this
+      this.sbId = key
+      // 日期处理
+
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign({
+          'sbId': key,
+          'sbName': row.name
+        }))
+      })
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      // this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          Object.values(errors).map(item => {
+            this.$message.error(item.errors[0].message)
+          })
+          this.confirmLoading = false
+        }
+        addPurchaseOrder2(values).then(res => {
+          this.$message.success('创建成功!')
+        })
+      })
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.form.resetFields()
+      this.sbIds = []
+      this.$emit('ok', values)
+    }
+
+  }
+}
+</script>
+<style lang="less" scoped>
+.tooltip{
+  font-size:20px;
+  color:#ccc;
+  &:hover {
+  color:#2f54eb;
+  }
+}
+</style>

+ 358 - 0
src/views/purchase/purchase-order-page/modules/SbInfoSelectModal.vue

@@ -0,0 +1,358 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="1300"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+  >
+    <a-card :bordered="false">
+      <div class="table-page-search-wrapper">
+        <a-form layout="inline">
+          <a-row :gutter="48">
+            <a-col :md="8" :sm="24">
+              <a-form-item label="关键字">
+                <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/编码"/>
+              </a-form-item>
+            </a-col>
+            <!--            <a-col :md="8" :sm="24">
+              <a-form-item label="上层设备类型">
+                <a-tree-select
+                  style="width: 100%"
+                  :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
+                  :treeData="treeData"
+                  :treeNodeFilterProp="'title'"
+                  :showSearch="true"
+                  v-model="queryParam.parentId"
+                  placeholder="请选择"
+                >
+                </a-tree-select>
+              </a-form-item>
+            </a-col>-->
+            <a-col :md="6" :sm="24">
+              <a-form-item label="车间位置">
+                <a-select v-model="queryParam.positionId" placeholder="请选择">
+                  <a-select-option
+                    v-for="({id,name}) in sbPositionData"
+                    :key="id"
+                    :label="name"
+                    :value="id">{{ name }}
+                  </a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-item label="设备类型">
+                <a-tree-select
+                  style="width: 100%"
+                  :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
+                  :treeData="treeData"
+                  :treeNodeFilterProp="'title'"
+                  :showSearch="true"
+                  placeholder="请选择"
+                  @change="handleChange"
+                >
+                </a-tree-select>
+              </a-form-item>
+            </a-col>
+            <a-col :md="8 || 24" :sm="24">
+              <span class="table-page-search-submitButtons">
+                <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
+                <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
+              </span>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+
+      <div class="table-operator" style="margin-bottom: 8px;">
+      </div>
+
+      <s-table
+        ref="table"
+        size="default"
+        rowKey="id"
+        :columns="columns"
+        :data="loadData"
+        :alert="options.alert"
+        :customRow="options.customRow"
+        :rowSelection="options.rowSelection"
+        :scroll="{ x: 1300, y: BaseTool.Constant.scrollY }"
+        showPagination="auto"
+      >
+        <span slot="action" slot-scope="record">
+          <template>
+
+          </template>
+        </span>
+        <span slot="status" slot-scope="text">
+          <badge :status="DictCache.COLOR.SB_INFO_STATUS[text]" :text="statusMap[text]" />
+        </span>
+      </s-table>
+    </a-card>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">取消</a-button>
+      <a-button :loading="confirmLoading" type="primary" @click="handleSelect()">选择</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import { STable, Ellipsis } from '@/components'
+import { getSbInfoPage, fetchSbInfo, getSbInfoTree } from '@/api/sb/info'
+import { querySbPosition } from '@/api/sb/position'
+import { fetchSbTypeTree } from '@/api/sb/type'
+
+export default {
+  name: 'SbInfoSelectModal',
+  components: {
+    STable,
+    Ellipsis
+  },
+  props: {
+    type: {
+      type: String,
+      default: 'radio'
+    },
+    selectedRowKey: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    selectedRow: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      mdl: {},
+      modalTitle: null,
+      visible: false,
+      // 查询参数
+      queryParam: {
+      },
+      extraQueryParam: {
+      },
+      depreciationTypeMap: {},
+      levelMap: {},
+      statusMap: {},
+      unitMap: {},
+      useTypeMap: {},
+      sourceTypeMap: {},
+      treeData: [],
+      sbPositionData: [],
+      typeList: [],
+      // 表头
+      columns: [
+        {
+          title: '设备名称',
+          checked: true,
+          dataIndex: 'name'
+        },
+        {
+          title: '设备编号',
+          dataIndex: 'no',
+          checked: true
+        },
+        {
+          title: '设备位号',
+          checked: true,
+          dataIndex: 'positionNo'
+        },
+        {
+          title: '型号',
+          checked: true,
+          dataIndex: 'model'
+        },
+        {
+          title: '设备类型',
+          dataIndex: 'type',
+          checked: true,
+          width: 200,
+          customRender: (text, record, index) => {
+            return record.typeName
+          }
+        },
+        {
+          title: '设备等级',
+          dataIndex: 'level',
+          checked: true,
+          width: 200,
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.levelMap, text)
+          }
+        },
+        {
+          title: '状态',
+          dataIndex: 'status',
+          checked: true,
+          width: 200,
+          scopedSlots: { customRender: 'status' }
+        },
+        {
+          title: '备注',
+          dataIndex: 'remark',
+          width: 200
+        },
+        {
+          title: '操作',
+          key: 'action',
+          width: '200px',
+          align: 'center',
+          fixed: 'right',
+          scopedSlots: { width: 200, customRender: 'action' }
+        }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        parameter = {
+          ...parameter,
+          ...this.queryParam,
+          ...this.extraQueryParam,
+          typeList: this.typeList,
+          dataScope: {
+            sortBy: 'asc',
+            sortName: 'no'
+          }
+        }
+        return getSbInfoPage(Object.assign(parameter, this.queryParam))
+          .then(res => {
+            return res.data
+          })
+      },
+      selectedRowKeys: [],
+      selectedRows: [],
+
+      options: {
+        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+        rowSelection: {
+          selectedRowKeys: this.selectedRowKeys,
+          onChange: this.onSelectChange
+        }
+      },
+      optionAlertShow: true,
+      isCreated: false
+    }
+  },
+  created () {
+    this.tableOption()
+    this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
+    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
+    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
+    this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
+    this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
+    this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_UES_TYPE)
+    querySbPosition().then(res => {
+      this.sbPositionData = res.data
+    })
+    fetchSbTypeTree().then(res => {
+      this.treeData = res.data
+    })
+  },
+  methods: {
+    tableOption () {
+      // this.setTree()
+      if (!this.optionAlertShow) {
+        this.options = {
+          alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+          rowSelection: {
+            selectedRowKeys: this.selectedRowKeys,
+            onChange: this.onSelectChange,
+            type: this.type,
+            getCheckboxProps: record => ({
+              props: {
+                disabled: false,
+                name: record.id
+              }
+            })
+          },
+          customRow: (record) => {
+            return {
+              on: { // 事件
+                click: (event) => { // 点击行
+                  // 选择对象
+                  this.mySelect([record.id], [record])
+                },
+                dblclick: (event) => {
+                  this.mySelect([record.id], [record])
+                  this.handleSelect()
+                }
+              }
+            }
+          }
+        }
+        this.optionAlertShow = true
+      } else {
+        this.options = {
+          alert: false,
+          rowSelection: null
+        }
+        this.optionAlertShow = false
+      }
+    },
+    handleOk () {
+      // this.setTree()
+      this.$refs.table.refresh()
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    resetSearchForm () {
+      this.queryParam = {
+      }
+      this.$refs.table.refresh(true)
+    },
+    /**
+     * 设置设备类型树
+     */
+    base (record, queryParam = {}) {
+      this.visible = true
+      this.modalTitle = '选择设备'
+      this.queryParam = queryParam
+      if (this.isCreated) {
+        console.log(this.$refs.table)
+        this.$refs.table.clearSelected()
+        this.options.rowSelection.type = this.type
+        this.handleOk()
+      } else {
+        this.tableOption()
+        this.isCreated = true
+      }
+      // this.mySelect(this.selectedRowKeys, this.selectedRows)
+    },
+    handleCancel () {
+      this.visible = false
+      this.confirmLoading = false
+    },
+    handleSelect () {
+      if (this.selectedRowKeys.length === 0) {
+        this.$message.warn('请至少选择一项信息')
+      } else {
+        this.confirmLoading = true
+        this.$emit('selected', this.selectedRowKeys, this.selectedRows)
+        this.confirmLoading = false
+        this.visible = false
+      }
+    },
+    mySelect (selectedRowKeys, selectedRows) {
+      this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
+      this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
+    },
+    handleChange (value, label, extra) {
+      const data = this.treeData.find(item => item.id === value)
+      if (data && data.children && data.children.length > 0) {
+        this.typeList = data.children.map(item => item.id)
+      } else {
+        this.typeList = [value]
+      }
+    }
+  }
+}
+</script>

+ 2 - 2
src/views/purchase/purchase-order-record/PurchaseOrderRecord.vue

@@ -56,7 +56,7 @@
 
 <script>
 import { STable, Ellipsis } from '@/components'
-import { getPurchaseOrderPage2, deletePurchaseOrders } from '@/api/purchase/purchase-order'
+import { getpurchaseRecord, deletePurchaseOrders } from '@/api/purchase/purchase-order'
 
 export default {
   name: 'PurchaseOrderList',
@@ -243,7 +243,7 @@ export default {
             sortName: 'status,update_time'
           }
         }
-        return getPurchaseOrderPage2(Object.assign(parameter, this.queryParam))
+        return getpurchaseRecord(Object.assign(parameter, this.queryParam))
           .then(res => {
             return res.data
           })

+ 210 - 289
src/views/purchase/purchase-order-report/PurchaseOrderReport.vue

@@ -1,334 +1,255 @@
 <template>
-  <a-card :bordered="false">
-    <div v-show="visible">
-      <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
-        <a-form layout="inline">
-          <a-row :gutter="48">
-            <a-col :md="8" :sm="24">
-              <a-form-item label="关键字">
-                <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
-              </a-form-item>
-            </a-col>
-            <a-col :md="8 || 24" :sm="24">
-              <span class="table-page-search-submitButtons">
-                <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
-                <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
-              </span>
-            </a-col>
-          </a-row>
-        </a-form>
+  <div class="page-header-index-wide">
+    <a-card :title="title" :loading="loading" v-show="visible" :bordered="false" :body-style="{padding: '0'}">
+      <div class="salesCard">
+        <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
+          <div class="extra-wrapper" slot="tabBarExtraContent">
+            <a-date-picker
+              style="margin-left: 8px"
+              :default-value="moment(defaultStartMonth, monthFormat)"
+              :format="monthFormat"
+              showTime
+              v-model="queryParam.startTime"
+              placeholder="开始月份"
+              @change="onStartChange" />
+            <a-date-picker
+              style="margin-left: 8px"
+              :default-value="moment(defaultEndMonth, monthFormat)"
+              :format="monthFormat"
+              showTime
+              v-model="queryParam.endTime"
+              placeholder="结束月份"
+              @change="onEndChange" />
+            <a-button style="margin-left: 8px" type="default" @click="getData()">查询</a-button>
+            <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrint()">打印</a-button>
+            <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button>
+          </div>
+          <a-tab-pane loading="true" tab="图形统计" key="1">
+            <a-row>
+              <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
+                <div style="padding: 10px">
+                  <div id="container" style="width: 100%;overflow-x:auto"></div>
+                </div>
+              </a-col>
+            </a-row>
+          </a-tab-pane>
+          <a-tab-pane loading="true" tab="表格统计" key="2">
+            <a-row>
+              <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
+                <div style="padding: 10px">
+                  <a-table
+                    bordered
+                    :data-source="chartsData"
+                    :columns="columns"
+                    tableLayout="auto"
+                    :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
+                    rowKey="month">
+                    <span slot="action" slot-scope="record">
+                      <template>
+                        <a @click="handleView(record)">查看明细</a>
+                        <a-divider type="vertical" />
+                        <a @click="doExportDetail(record)">导出</a>
+                      </template>
+                    </span>
+                  </a-table>
+                </div>
+              </a-col>
+            </a-row>
+          </a-tab-pane>
+        </a-tabs>
       </div>
-
-      <div class="table-operator" style="margin-bottom: 8px;">
-        <!--      <a-button v-if="$auth('purchase-purchase-orders-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
-        <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-orders-del')">
-          <a-menu slot="overlay">
-            <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
-              <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
-            </a-popconfirm>
-          </a-menu>
-          <a-button style="margin-left: 8px">
-            批量操作 <a-icon type="down" />
-          </a-button>
-        </a-dropdown>
-      </div>
-
-      <s-table
-        ref="table"
-        size="default"
-        rowKey="id"
-        :columns="columns"
-        :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
-        :data="loadData"
-        :alert="options.alert"
-        :rowSelection="options.rowSelection"
-        showPagination="auto"
-      >
-        <span slot="action" slot-scope="record">
-          <template>
-          </template>
-        </span>
-      </s-table>
-    </div>
-    <!--    <purchase-dispatch-order ref="dispatchOrder" @ok="handleOk"/>-->
-  </a-card>
+    </a-card>
+    <print-in-repair-report ref="basePrintModal" @ok="handleOk"/>
+    <detail-repair-report ref="detailModal" @ok="handleOk"/>
+  </div>
 </template>
 
 <script>
-import { STable, Ellipsis } from '@/components'
-import { getPurchaseOrderPage2, deletePurchaseOrders } from '@/api/purchase/purchase-order'
+import { getMonthReportBig24, exportMonthReportBig24, exportMonthReportBig24Month } from '@/api/report/application-form'
+import { Chart } from '@antv/g2'
+import PrintInRepairReport from '@/views/dashboard/modules/PrintInRepairReport'
+import DetailRepairReport from '@/views/dashboard/modules/DetailRepairReport'
+import moment from 'moment'
+import { getPurchaseReport } from '@/api/purchase/purchase-order'
 
 export default {
-  name: 'PurchaseOrderList',
+  name: 'Analysis',
   components: {
-    STable,
-    Ellipsis
+    PrintInRepairReport,
+    Chart,
+    DetailRepairReport
+  },
+  props: {
+    /**
+     * 检查类型: 1->24小时非计划性维修 2-全部维修(不包括其他临时完善维修)
+     */
+    searchType: {
+      type: Number,
+      default: 1
+    },
+    title: {
+      type: String,
+      default: '大于24小时非计划性维修'
+    }
   },
   data () {
     return {
-      // 查询参数
+      loading: false,
+      serverData: [],
+      monthFormat: 'YYYY-MM-DD',
+      defaultStartMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR_MONTH) + '-01 00:00:00',
+      defaultEndMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN),
       queryParam: {
+        // year: 2021,
+        startTime: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR_MONTH) + '-01 00:00:00',
+        endTime: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
       },
       visible: true,
-      user: this.$store.getters.userInfo,
-      dollarExchangeRate: this.$store.getters.rmbRate,
+      chart: null, // 创建一个chart变量
+      chartsData: [],
       // 表头
       columns: [
         {
-          title: '序号',
-          dataIndex: 'index',
-          checked: true,
-          width: 70,
-          customRender: (text, record, index) => {
-            return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
-          }
-        },
-        {
-          title: '单号',
-          dataIndex: 'billNo',
-          checked: true,
-          width: 200
-        },
-        {
-          title: '公司名称',
-          dataIndex: 'companyName',
-          checked: true,
-          width: 150
-        },
-        {
-          title: '项目名称',
-          dataIndex: 'projectName',
-          checked: true,
-          width: 150
-        },
-        {
-          title: '采购员名称',
-          dataIndex: 'purchaserName',
-          checked: true,
-          width: 150
-        },
-        {
-          title: '项目记账币种',
-          dataIndex: 'projectMoneyType',
-          checked: true,
-          width: 120,
-          customRender: (text, record, index) => {
-            return this.BaseTool.Table.getMapText(this.moneyTypeMap, text)
-          }
-        },
-        {
-          title: '类型',
-          dataIndex: 'type',
-          checked: true,
-          width: 100,
-          customRender: (text, record, index) => {
-            return this.BaseTool.Table.getMapText(this.typeMap, text)
-          }
+          title: '月份',
+          width: 180,
+          dataIndex: 'month'
         },
-        {
-          title: '需求日期',
-          dataIndex: 'demandDate',
-          checked: true,
-          width: 150
-        },
-
-        {
-          title: '预计总金额',
-          dataIndex: 'originMoney',
-          checked: true,
-          width: 120,
-          customRender: (text, record, index) => {
-            let dollarExchangeRate = 1
-            if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
-              dollarExchangeRate = this.dollarExchangeRate
-            }
-            return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
-          }
-        },
-        {
-          title: '实际总金额(按记账主币)',
-          dataIndex: 'accountMoney',
-          checked: true,
-          width: 120,
-          customRender: (text, record, index) => {
-            let dollarExchangeRate = 1
-            if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
-              dollarExchangeRate = this.dollarExchangeRate
-            }
-            return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
-          }
-        },
-        {
-          title: '实际总金额(按询价主币)',
-          dataIndex: 'money',
-          checked: true,
-          width: 120,
-          customRender: (text, record, index) => {
-            return this.BaseTool.Amount.formatter(text) + this.BaseTool.Table.getMapTextForMoneyType(this.moneyTypeMap, record.moneyType)
-          }
-        },
-        {
-          title: '总费用(按记账主币,含发运)',
-          dataIndex: 'accountTotalMoney',
-          checked: true,
-          width: 150,
-          customRender: (text, record, index) => {
-            let dollarExchangeRate = 1
-            if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
-              dollarExchangeRate = this.dollarExchangeRate
-            }
-            return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
-          }
-        },
-        // {
-        //   title: '总费用(按询价主币)',
-        //   dataIndex: 'totalMoney',
-        //   checked: true,
-        //   width: 120,
-        //   customRender: (text, record, index) => {
-        //     return this.BaseTool.Amount.formatter(text) + this.BaseTool.Table.getMapTextForMoneyType(this.moneyTypeMap, record.moneyType)
-        //   }
-        // },
         {
           title: '数量',
-          dataIndex: 'quantity',
-          checked: true,
-          width: 90,
-          customRender: (text, record, index) => {
-            return this.BaseTool.Amount.formatter(text)
-          }
-        },
-        {
-          title: '状态',
-          dataIndex: 'status',
-          checked: true,
-          fixed: 'right',
-          width: 100,
-          customRender: (text, record, index) => {
-            return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
-              this.DictCache.COLOR.PURCHASE_ORDER_STATUS, this.statusMap)
-          }
-        },
-        {
-          title: '备注',
-          width: 100,
-          dataIndex: 'remark'
+          width: 120,
+          dataIndex: 'num'
         },
         {
           title: '操作',
           key: 'action',
           width: '200px',
-          fixed: 'right',
-          checked: true,
           align: 'center',
           scopedSlots: { customRender: 'action' }
         }
-      ],
-      // 下拉框map
-      typeMap: {},
-      statusMap: {},
-      payTypeMap: {},
-      invoiceTypeMap: {},
-      moneyTypeMap: {},
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        const user = this.$store.getters.userInfo
-        const roleCodes = user.roleCodes.join(',')
-        parameter = {
-          ...parameter,
-          ...this.queryParam,
-          projectId: roleCodes.indexOf('FGS_') > -1 ? null : user.projectId,
-          dataScope: {
-            sortBy: 'asc,desc',
-            sortName: 'status,update_time'
-          }
-        }
-        return getPurchaseOrderPage2(Object.assign(parameter, this.queryParam))
-          .then(res => {
-            return res.data
-          })
-      },
-      selectedRowKeys: [],
-      selectedRows: [],
-
-      options: {
-        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
-        rowSelection: {
-          selectedRowKeys: this.selectedRowKeys,
-          onChange: this.onSelectChange
-        }
-      },
-      optionAlertShow: false
+      ]
     }
   },
   created () {
-    // 下拉框map
-    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_APPLY_TYPE)
-    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_ORDER_STATUS)
-    this.payTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_PAY_TYPE)
-    this.invoiceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_INVOICE_TYPE)
-    this.moneyTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.MONEY_TYPE)
-    this.tableOption()
+  },
+  mounted () {
+    this.$nextTick(function () {
+      this.getData()
+    })
   },
   methods: {
-    tableOption () {
-      if (!this.optionAlertShow) {
-        this.options = {
-          alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
-          rowSelection: {
-            selectedRowKeys: this.selectedRowKeys,
-            onChange: this.onSelectChange,
-            getCheckboxProps: record => ({
-              props: {
-                disabled: false,
-                name: record.id
-              }
-            })
-          }
-        }
-        this.optionAlertShow = true
-      } else {
-        this.options = {
-          alert: false,
-          rowSelection: null
-        }
-        this.optionAlertShow = false
-      }
+    moment,
+    onStartChange (date, dateString) {
+      this.queryParam.startMonth = this.BaseTool.Date.formatter(dateString + '-01', this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
     },
-    handleOk () {
-      this.visible = true
-      this.$refs.table.refresh()
+    onEndChange (date, dateString) {
+      this.queryParam.endMonth = this.BaseTool.Date.formatter(dateString + '-01', this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
     },
-    onSelectChange (selectedRowKeys, selectedRows) {
-      this.selectedRowKeys = selectedRowKeys
-      this.selectedRows = selectedRows
+    getData () {
+      getPurchaseReport(this.queryParam)
+        .then(res => {
+          this.chartsData = res.data
+          this.getCharts('container', this.chartsData)// 调用统计图
+        })
     },
-    resetSearchForm () {
-      this.queryParam = {
+    getCharts (id, data) {
+      this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
+      this.chart = new Chart({
+        container: 'container',
+        autoFit: true,
+        height: 400
+      })
+      this.chart.data(data)
+      this.chart.scale('num', {
+        nice: true
+      })
+      this.chart.tooltip({
+        showMarkers: true,
+        shared: true
+      })
+      this.chart.interval().position('month*num')
+      this.chart.interaction('active-region')
+      this.chart.legend({
+        position: 'bottom'
+      })
+      this.chart.render()
+    },
+    doExport () {
+      const parameter = {
+        ...this.queryParam
       }
-      this.$refs.table.refresh(true)
+      exportMonthReportBig24(parameter).then(file => {
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
+      })
     },
-    batchDelete (id) {
-      let ids = []
-      if (this.BaseTool.String.isBlank(id)) {
-        const length = this.selectedRows.length
-        if (length === 0) {
-          this.$message.info('请选择要删除的记录')
-          return
-        }
-        ids = this.selectedRows.map(item => item.id)
-      } else {
-        ids = [id]
+    doExportDetail (record) {
+      const parameter = {
+        ...this.queryParam,
+        month: record.month,
+        year: record.year
       }
-      deletePurchaseOrders(ids).then(res => {
-        this.$message.info('删除成功')
-        this.handleOk()
-        this.$refs.table.clearSelected()
+      exportMonthReportBig24Month(parameter).then(file => {
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
     },
-    handleEnter () {
-      this.$refs.table.refresh(true)
+    handlePrint (record) {
+      const modal = this.$refs.basePrintModal
+      this.visible = false
+      modal.base({ startMonth: this.queryParam.startMonth, endMonth: this.queryParam.endMonth, title: this.title, data: this.chartsData })
+    },
+    handleView (record) {
+      console.log(111)
+      console.log(record)
+      const modal = this.$refs.detailModal
+      modal.base(record)
+    },
+    handleOk () {
+      this.visible = true
     }
   }
 }
 </script>
+
+<style lang="less" scoped>
+  .extra-wrapper {
+    line-height: 55px;
+    padding-right: 24px;
+
+    .extra-item {
+      display: inline-block;
+      margin-right: 24px;
+
+      a {
+        margin-left: 24px;
+      }
+    }
+  }
+
+  .antd-pro-pages-dashboard-analysis-twoColLayout {
+    position: relative;
+    display: flex;
+    display: block;
+    flex-flow: row wrap;
+  }
+
+  .antd-pro-pages-dashboard-analysis-salesCard {
+    height: calc(100% - 24px);
+    /deep/ .ant-card-head {
+      position: relative;
+    }
+  }
+
+  .dashboard-analysis-iconGroup {
+    i {
+      margin-left: 16px;
+      color: rgba(0,0,0,.45);
+      cursor: pointer;
+      transition: color .32s;
+      color: black;
+    }
+  }
+  .analysis-salesTypeRadio {
+    position: absolute;
+    right: 54px;
+    bottom: 12px;
+  }
+</style>