|
@@ -112,6 +112,12 @@
|
|
|
@click="openDetails(scope.row)"
|
|
|
v-hasPermi="['groupBuyingMr:groupBuyingMr:details']"
|
|
|
>详情</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ @click="handleOpen([scope.row])"
|
|
|
+ v-hasPermi="['orderMr:orderMr:print']"
|
|
|
+ >打印小票</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -127,6 +133,24 @@
|
|
|
<!-- 详情 -->
|
|
|
<details-dia ref="detailsDia" :dict="dict" @getList="getList"></details-dia>
|
|
|
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="选择小票机"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ width="30%"
|
|
|
+ :before-close="handleClose">
|
|
|
+ <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
|
|
+ <el-form-item label="小票机" prop="region">
|
|
|
+ <el-select v-model="ruleForm.region" placeholder="选择小票机">
|
|
|
+ <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -135,6 +159,8 @@
|
|
|
import { pageList } from '@/api/order/groupBuyingMr'
|
|
|
import detailsDia from "./dialog/details.vue";
|
|
|
|
|
|
+import { printApi } from '@/api/order/orderMr'
|
|
|
+import { pageList as getPrintListApi } from "@/api/device/pda";
|
|
|
export default {
|
|
|
name: "agreement",
|
|
|
dicts: ['agreement_type', 'team_type'],
|
|
@@ -219,7 +245,19 @@ export default {
|
|
|
],
|
|
|
visibleStatus: false,
|
|
|
newObj: {},
|
|
|
- visibleType: ''
|
|
|
+ visibleType: '',
|
|
|
+
|
|
|
+
|
|
|
+ viewerList: [],
|
|
|
+ printList: [],
|
|
|
+ dialogVisible: false,
|
|
|
+ ruleForm: {},
|
|
|
+ rules: {
|
|
|
+ region: [
|
|
|
+ { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ dialogVisibleLoading: false,
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -267,6 +305,87 @@ export default {
|
|
|
openDetails(row, type) {
|
|
|
this.$refs["detailsDia"].openDialog("详情", row, type);
|
|
|
},
|
|
|
+ handleOpen(list=[]){
|
|
|
+ if(!list||list.length==0) return
|
|
|
+ let idList = []
|
|
|
+ list.forEach((item,index)=>{
|
|
|
+ idList.push(item.id)
|
|
|
+ })
|
|
|
+ this.viewerList = idList
|
|
|
+ this.getPrintListApi()
|
|
|
+ this.$set(this.ruleForm, 'region', '');
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.$refs.ruleForm.clearValidate('region')
|
|
|
+ })
|
|
|
+ this.dialogVisible = true
|
|
|
+ },
|
|
|
+ handleClose(){
|
|
|
+ this.dialogVisible = false
|
|
|
+ },
|
|
|
+ /** 查询打印机列表 */
|
|
|
+ getPrintListApi() {
|
|
|
+ getPrintListApi({deviceType:5,pageNum: 1,
|
|
|
+ pageSize: 999,})
|
|
|
+ .then(response => {
|
|
|
+ this.printList = response.data.rows;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /** 选择打印机 */
|
|
|
+ selectPrint(){
|
|
|
+
|
|
|
+ },
|
|
|
+ // 打印
|
|
|
+ async print(list = []){
|
|
|
+ this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.dialogVisibleLoading = true
|
|
|
+ try {
|
|
|
+ let res = await printApi({
|
|
|
+ viewerList:list,
|
|
|
+ source: 2,
|
|
|
+ deviceId: this.ruleForm.region
|
|
|
+ })
|
|
|
+ if(res.code == 200) {
|
|
|
+ let url = res.data.linkIp
|
|
|
+ let printInfo = res.data.printInfo
|
|
|
+ this.connectPrint(url,printInfo)
|
|
|
+ }else {
|
|
|
+ throw new Error(res)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.dialogVisibleLoading = false
|
|
|
+ console.error("error=====",error)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ /** 连接打印机 */
|
|
|
+ connectPrint(url,data){
|
|
|
+ let xhr = new XMLHttpRequest();
|
|
|
+ xhr.onreadystatechange = ()=>{
|
|
|
+ if(xhr.readyState == 4){ // 监听请求完成
|
|
|
+ if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
|
|
|
+ console.log(xhr.responseText)
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.dialogVisibleLoading = false
|
|
|
+ }else{
|
|
|
+ console.log('请求失败')
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.dialogVisibleLoading = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ xhr.open("post", url, true); // 异步请求
|
|
|
+ xhr.send(JSON.stringify(data));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|