labelPrint.vue 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <template>
  2. <div class="main-contain outpatientChargesManagement">
  3. <div class="position">
  4. <bread-crumb :crumbs='crumbs'></bread-crumb>
  5. </div>
  6. <div>
  7. <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
  8. <div>
  9. <el-input style="width:150px;" v-model="keywords" @input="searchAction"
  10. @keyup.enter.native='searchAction'
  11. placeholder="请输入患者姓名"
  12. class="filter-item"/>
  13. <el-select v-model="item_type" placeholder="请选择"
  14. style="width:150px;" @change="changeItem">
  15. <el-option
  16. label="全部"
  17. value="0">
  18. </el-option>
  19. <el-option
  20. v-for="item,index in items"
  21. :key="index"
  22. :label="item.name"
  23. :value="item.id">
  24. </el-option>
  25. </el-select>
  26. <el-date-picker
  27. v-model="chargeDate"
  28. type="date"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd"
  31. @change="changeDate"
  32. >
  33. </el-date-picker>
  34. <el-select v-model="tube_color" style="width:160px;" placeholder="请选择" @change="changeItemTwo">
  35. <el-option
  36. label="全部"
  37. value="0">
  38. </el-option>
  39. <el-option
  40. v-for="(item,index) in getDictionaryDataConfig('system','tube_color')"
  41. :key="index"
  42. :label="item.name"
  43. :value="item.id">
  44. </el-option>
  45. </el-select>
  46. <el-button @click="printThree()">批量打印</el-button>
  47. <el-checkbox v-model="is_combination_print">是否组合打印</el-checkbox>
  48. <!-- <el-checkbox @click="printTwo()">批量打印</el-checkbox>-->
  49. <el-button v-if="!is_combination_print && $store.getters.xt_user.org.id == 10138" @click="printTwo()">组合打印</el-button>
  50. </div>
  51. </div>
  52. <el-table :data="isShow?tableData:tableDataTwo" border :row-style="{ color: '#303133' }" ref="table"
  53. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  54. @selection-change="handleSelectionChange"
  55. highlight-current-row>
  56. <el-table-column align="center" type="selection" width="55"></el-table-column>
  57. <el-table-column align="center" prop="name" label="患者名字">
  58. <template slot-scope="scope">{{ scope.row.patient_name }}</template>
  59. </el-table-column>
  60. <el-table-column align="center" prop="name" label="处方号">
  61. <template slot-scope="scope">{{scope.row.number}}</template>
  62. </el-table-column>
  63. <el-table-column align="center" prop="name" label="创建时间">
  64. <template slot-scope="scope">
  65. <div v-if="isShow">{{getTime(scope.row.record_date, '{y}-{m}-{d}')}}</div>
  66. <div v-if="!isShow">{{scope.row.record_date}}</div>
  67. </template>
  68. </el-table-column>
  69. <el-table-column align="center" prop="name" label="创建医生">
  70. <template slot-scope="scope">{{scope.row.doctor_name}}</template>
  71. </el-table-column>
  72. <el-table-column align="center" prop="name" label="项目名称">
  73. <template slot-scope="scope">
  74. <div>{{scope.row.project_name}}</div>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. align="center"
  79. label="操作"
  80. width="180"
  81. class-name="small-padding fixed-width"
  82. >
  83. <template slot-scope="scope">
  84. <el-tooltip class="item" effect="dark" content="打印" placement="top">
  85. <el-button
  86. type="primary"
  87. size="small"
  88. icon="el-icon-printer"
  89. @click="Print(scope.row, scope.$index)"
  90. >
  91. <!-- icon="el-icon-edit-outline" -->
  92. </el-button>
  93. </el-tooltip>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <el-pagination
  98. v-if="isShow"
  99. @size-change="handleSizeChange"
  100. @current-change="handleCurrentChange"
  101. :page-sizes="[10, 50, 100]"
  102. :page-size="10"
  103. background
  104. style="margin-top:20px;float: right"
  105. layout="total, sizes, prev, pager, next, jumper"
  106. :total="total"
  107. >
  108. </el-pagination>
  109. </div>
  110. <el-dialog title="打印" :visible.sync="labelVisible">
  111. <div>
  112. <el-row style="float:right;">
  113. <el-col :span="24">
  114. <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印
  115. </el-button>
  116. </el-col>
  117. </el-row>
  118. <div id="sign" class="signPrint">
  119. <div style="display:flex;margin-bottom:10px;">
  120. <div style="margin-left:15px;">
  121. <div style="font-weight:bold;font-size:24px;">C</div>
  122. <div>{{getTime(current_ctime,'{m}-{d}')}}</div>
  123. <div>{{getTime(current_ctime,'{h}:{i}')}}</div>
  124. </div>
  125. <img v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217" id="barcode">
  126. </div>
  127. <div style="margin-bottom:5px;">{{current_number}}</div>
  128. <div style="display:flex;">
  129. <div style="font-size:24px;padding-left:20px;">{{current_project_name}}</div>
  130. <div style="font-size:24px;margin-left:20px;">{{current_name}}</div>
  131. </div>
  132. </div>
  133. </div>
  134. <div slot="footer" class="dialog-footer">
  135. <el-button @click="labelVisible = false">取 消</el-button>
  136. <el-button type="primary" @click="labelVisible = false">确 定</el-button>
  137. </div>
  138. </el-dialog>
  139. <el-dialog title="批量打印" :visible.sync="batchLabelVisible">
  140. <div>
  141. <el-row style="float:right;">
  142. <el-col :span="24">
  143. <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印
  144. </el-button>
  145. </el-col>
  146. </el-row>
  147. <div id="sign" class="signPrint">
  148. <div v-for="item in selecting_schs">
  149. <div style="display:flex;margin-bottom:10px;" >
  150. <div style="margin-left:15px;">
  151. <div style="font-weight:bold;font-size:24px;">C</div>
  152. <div>{{getTime(item.ctime,'{m}-{d}')}}</div>
  153. <div>{{getTime(item.ctime,'{h}:{i}')}}</div>
  154. </div>
  155. <img v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217" id="barcode">
  156. </div>
  157. <div style="margin-bottom:5px;">{{item.number}}</div>
  158. <div style="display:flex;">
  159. <div style="font-size:24px;padding-left:20px;">{{item.project_name}}</div>
  160. <div style="font-size:24px;margin-left:20px;">{{item.patient_name}}</div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. <div slot="footer" class="dialog-footer">
  166. <el-button @click="batchLabelVisible = false">取 消</el-button>
  167. <!-- <el-button type="primary" @click="labelVisible = false">确 定</el-button>-->
  168. </div>
  169. </el-dialog>
  170. </div>
  171. </template>
  172. <script>
  173. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  174. import { GetLabelList,getColorTubeLablePrints,createPrintLable,getPrintLable } from '@/api/his/his'
  175. import { uParseTime } from '@/utils/tools'
  176. import SignPrint from '../dialysis/signPrint'
  177. import JsBarcode from 'jsbarcode'
  178. import { getDictionaryDataConfig } from '@/utils/data'
  179. // import NewStatementPrint from './newStatementPrint'
  180. const moment = require('moment')
  181. export default {
  182. components: {
  183. SignPrint,
  184. BreadCrumb
  185. },
  186. data() {
  187. return {
  188. isShow:true,
  189. tube_color:"0",
  190. tube_color_two:"0",
  191. is_combination_print:false,
  192. current_ctime: 0,
  193. current_number: '',
  194. current_project_name: '',
  195. current_name: '',
  196. selecting_schs:[],
  197. labelVisible: false,
  198. crumbs: [
  199. { path: false, name: 'HIS工具' },
  200. { path: false, name: '标签打印' }
  201. ],
  202. detail_loading: false,
  203. tempArr: [],
  204. pos: 0,
  205. page: 1,
  206. limit: 10,
  207. total: 0,
  208. current_id: 0,
  209. sameRowArr: [],
  210. keywords: '',
  211. tableData: [],
  212. tableDataTwo: [],
  213. current_params:{},
  214. chargeDate: moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
  215. item_type: '0',
  216. items: [
  217. { id: 1, name: '已打印' },
  218. { id: 2, name: '未打印' }
  219. ],
  220. batchLabelVisible:false,
  221. }
  222. },
  223. methods: {
  224. printThree(){
  225. this.batchLabelVisible = true
  226. },
  227. printTwo(){
  228. if(this.selecting_schs.length == 0){
  229. this.$message.error("请选择需要组合打印的记录")
  230. return
  231. }
  232. let patient_ids = []
  233. for(let i = 0; i < this.selecting_schs.length; i++){
  234. patient_ids.push(this.selecting_schs[i].patient_id)
  235. }
  236. patient_ids = this.uniqueTwo(patient_ids)
  237. if(patient_ids.length != 0 && patient_ids.length > 1){
  238. this.$message.error("请选择同一患者打印")
  239. return
  240. }else{
  241. var name = ""
  242. var patient_name = ""
  243. var team_ids = ""
  244. var ids = ""
  245. var project_ids = ""
  246. for(let i = 0; i < this.selecting_schs.length; i++){
  247. if(ids.length == 0){
  248. ids = this.selecting_schs[i].id
  249. }else{
  250. ids = ids + "," + this.selecting_schs[i].id
  251. }
  252. patient_name = this.selecting_schs[0].patient_name
  253. if(name.length == 0){
  254. name = this.selecting_schs[i].project_name
  255. }else{
  256. name = name + "," + this.selecting_schs[i].project_name
  257. }
  258. if(team_ids.length == 0){
  259. if(this.selecting_schs[i].item_id > 0) {
  260. team_ids = this.selecting_schs[i].item_id
  261. }
  262. }else{
  263. if(this.selecting_schs[i].item_id > 0) {
  264. team_ids = team_ids + "," + this.selecting_schs[i].item_id
  265. }
  266. }
  267. if(project_ids.length == 0){
  268. console.log(this.selecting_schs[i])
  269. if(this.selecting_schs[i].item_id == 0) {
  270. project_ids = this.selecting_schs[i].project_id
  271. console.log(project_ids)
  272. }
  273. }else{
  274. if(this.selecting_schs[i].item_id == 0) {
  275. project_ids = project_ids + "," + this.selecting_schs[i].project_id
  276. console.log(project_ids)
  277. }
  278. }
  279. }
  280. console.log(project_ids)
  281. let params = {
  282. patient_id: patient_ids[0],
  283. ids: ids,
  284. record_date:this.chargeDate,
  285. }
  286. getPrintLable(params).then(response => {
  287. if (response.data.state == 0) {
  288. this.$message.error(response.data.msg)
  289. return false
  290. } else {
  291. this.labelVisible = true
  292. if(response.data.data.labels.id > 0){
  293. this.current_ctime = response.data.data.labels.ctime
  294. this.current_number = ""
  295. this.current_project_name =name
  296. this.current_name = patient_name
  297. this.$nextTick(() => {
  298. JsBarcode('#barcode',response.data.data.labels.id, {
  299. format: 'CODE39',
  300. lineColor: '#000',
  301. background: '#EBEEF5',
  302. width: 3,
  303. height: 100,
  304. displayValue: true,
  305. text:response.data.data.labels.id,
  306. fontOptions:"bold italic",//使文字加粗体或变斜体
  307. font:"fantasy",//设置文本的字体
  308. textAlign:"left",//设置文本的水平对齐方式
  309. textPosition:"top",//设置文本的垂直位置
  310. textMargin:5,//设置条形码和文本之间的间距
  311. fontSize:15,//设置文本的大小
  312. margin:15//设置条形码周围的空白边距
  313. })
  314. });
  315. }else{
  316. let params = {
  317. is_combination_print:this.is_combination_print,
  318. patient_id: patient_ids[0],
  319. ids:ids,
  320. team_ids:team_ids,
  321. project_ids:project_ids,
  322. doctor_id:0,
  323. is_team:0,
  324. record_date:this.chargeDate,
  325. }
  326. this.current_params = params
  327. console.log(this.current_params)
  328. if(!this.current_params.is_combination_print){
  329. if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
  330. this.current_params.is_team = 0
  331. }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
  332. this.current_params.is_team= 1
  333. }
  334. }else{
  335. this.current_params.is_team = 0
  336. }
  337. if(!this.isShow){
  338. createPrintLable(this.current_params).then(response => {
  339. if (response.data.state == 0) {
  340. this.$message.error(response.data.msg)
  341. return false
  342. } else {
  343. this.current_ctime = response.data.data.hlpsi.ctime
  344. this.current_number = ""
  345. this.current_project_name = name
  346. this.current_name = patient_name
  347. this.$nextTick(() => {
  348. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  349. format: 'CODE39',
  350. lineColor: '#000',
  351. background: '#EBEEF5',
  352. width: 3,
  353. height: 200,
  354. displayValue: false,
  355. fontOptions:"bold italic",//使文字加粗体或变斜体
  356. font:"fantasy",//设置文本的字体
  357. textAlign:"left",//设置文本的水平对齐方式
  358. textPosition:"top",//设置文本的垂直位置
  359. textMargin:5,//设置条形码和文本之间的间距
  360. fontSize:15,//设置文本的大小
  361. margin:15//设置条形码周围的空白边距
  362. })
  363. });
  364. }
  365. })
  366. }else{
  367. createPrintLable(this.current_params).then(response => {
  368. if (response.data.state == 0) {
  369. this.$message.error(response.data.msg)
  370. return false
  371. } else {
  372. this.current_ctime = response.data.data.hlpsi.ctime
  373. this.current_number =""
  374. this.current_project_name = name
  375. this.current_name = patient_name
  376. this.$nextTick(() => {
  377. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  378. format: 'CODE39',
  379. lineColor: '#000',
  380. background: '#EBEEF5',
  381. width: 5,
  382. height: 300,
  383. displayValue: false,
  384. fontOptions:"bold italic",//使文字加粗体或变斜体
  385. font:"fantasy",//设置文本的字体
  386. textAlign:"left",//设置文本的水平对齐方式
  387. textPosition:"top",//设置文本的垂直位置
  388. textMargin:5,//设置条形码和文本之间的间距
  389. fontSize:15,//设置文本的大小
  390. margin:15//设置条形码周围的空白边距
  391. })
  392. });
  393. }
  394. })
  395. }
  396. }
  397. }
  398. })
  399. }
  400. },
  401. handleSelectionChange(val) {
  402. this.selecting_schs = val
  403. console.log(this.selecting_schs)
  404. },
  405. getDictionaryDataConfig(module, filed_name) {
  406. return getDictionaryDataConfig(module, filed_name)
  407. },
  408. printAction: function() {
  409. const style = '@media print { .sign{width:960px;margin: 0 auto;text-align: center;border-collapse: collapse;}.order_title_panl {text-align: center;.main_title {font-size: 18px;line-height: 40px;font-weight: 500;}}.dialysisTable tr{padding: 10px 0;}.dialysisTable th {color: #000;padding: 0;margin: 0;height: 30px;}.dialysisTable tr td {padding: 12px 0;}.subadvice_content {text-align: left;padding-left: 25px !important;padding-right: 5px !important;}.advice_content {text-align: left;padding-left: 5px !important;padding-right: 5px !important;padding: 15px 5px !important;} }'
  410. printJS({
  411. printable: 'sign',
  412. type: 'html',
  413. documentTitle: ' ',
  414. style: style,
  415. scanStyles: false
  416. })
  417. // createPrintLable(this.current_params).then(response => {
  418. // if (response.data.state == 0) {
  419. // this.$message.error(response.data.msg)
  420. // return false
  421. // } else {
  422. // const style = '@media print { .sign{width:960px;margin: 0 auto;text-align: center;border-collapse: collapse;}.order_title_panl {text-align: center;.main_title {font-size: 18px;line-height: 40px;font-weight: 500;}}.dialysisTable tr{padding: 10px 0;}.dialysisTable th {color: #000;padding: 0;margin: 0;height: 30px;}.dialysisTable tr td {padding: 12px 0;}.subadvice_content {text-align: left;padding-left: 25px !important;padding-right: 5px !important;}.advice_content {text-align: left;padding-left: 5px !important;padding-right: 5px !important;padding: 15px 5px !important;} }'
  423. // printJS({
  424. // printable: 'sign',
  425. // type: 'html',
  426. // documentTitle: ' ',
  427. // style: style,
  428. // scanStyles: false
  429. // })
  430. // }
  431. // })
  432. },
  433. getTime(value, temp) {
  434. if (value != undefined) {
  435. return uParseTime(value, temp)
  436. }
  437. return ''
  438. },
  439. Print(row, index) {
  440. let params = {
  441. patient_id: row.patient_id,
  442. ids: row.ids,
  443. record_date:this.chargeDate,
  444. }
  445. getPrintLable(params).then(response => {
  446. if (response.data.state == 0) {
  447. this.$message.error(response.data.msg)
  448. return false
  449. } else {
  450. this.labelVisible = true
  451. if(response.data.data.labels.id > 0){
  452. this.current_ctime = row.ctime
  453. this.current_number = row.number
  454. this.current_project_name = row.project_name
  455. this.current_name = row.patient_name
  456. this.$nextTick(() => {
  457. JsBarcode('#barcode',response.data.data.labels.id, {
  458. format: 'CODE39',
  459. lineColor: '#000',
  460. background: '#EBEEF5',
  461. width: 3,
  462. height: 200,
  463. displayValue: false,
  464. fontOptions:"bold italic",//使文字加粗体或变斜体
  465. font:"fantasy",//设置文本的字体
  466. textAlign:"left",//设置文本的水平对齐方式
  467. textPosition:"top",//设置文本的垂直位置
  468. textMargin:5,//设置条形码和文本之间的间距
  469. fontSize:15,//设置文本的大小
  470. margin:15//设置条形码周围的空白边距
  471. })
  472. });
  473. }else{
  474. let params = {
  475. is_combination_print:this.is_combination_print,
  476. patient_id: row.patient_id,
  477. ids: row.ids,
  478. team_ids: row.team_ids,
  479. project_ids:row.project_ids,
  480. doctor_id:row.doctor_id,
  481. is_team:0,
  482. record_date:this.chargeDate,
  483. }
  484. this.current_params = params
  485. console.log(this.current_params)
  486. if(!this.current_params.is_combination_print){
  487. if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
  488. this.current_params.is_team = 0
  489. }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
  490. this.current_params.is_team= 1
  491. }
  492. }else{
  493. this.current_params.is_team = 0
  494. }
  495. if(!this.isShow){
  496. createPrintLable(this.current_params).then(response => {
  497. if (response.data.state == 0) {
  498. this.$message.error(response.data.msg)
  499. return false
  500. } else {
  501. this.current_ctime = row.ctime
  502. this.current_number = row.number
  503. this.current_project_name = row.project_name
  504. this.current_name = row.patient_name
  505. this.$nextTick(() => {
  506. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  507. format: 'CODE39',
  508. lineColor: '#000',
  509. background: '#EBEEF5',
  510. width: 3,
  511. height: 200,
  512. displayValue: false,
  513. fontOptions:"bold italic",//使文字加粗体或变斜体
  514. font:"fantasy",//设置文本的字体
  515. textAlign:"left",//设置文本的水平对齐方式
  516. textPosition:"top",//设置文本的垂直位置
  517. textMargin:5,//设置条形码和文本之间的间距
  518. fontSize:15,//设置文本的大小
  519. margin:15//设置条形码周围的空白边距
  520. })
  521. });
  522. }
  523. })
  524. }else{
  525. createPrintLable(this.current_params).then(response => {
  526. if (response.data.state == 0) {
  527. this.$message.error(response.data.msg)
  528. return false
  529. } else {
  530. this.current_ctime = row.ctime
  531. this.current_number = row.number
  532. this.current_project_name = row.project_name
  533. this.current_name = row.patient_name
  534. this.$nextTick(() => {
  535. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  536. format: 'CODE39',
  537. lineColor: '#000',
  538. background: '#EBEEF5',
  539. width: 5,
  540. height: 300,
  541. displayValue: false,
  542. fontOptions:"bold italic",//使文字加粗体或变斜体
  543. font:"fantasy",//设置文本的字体
  544. textAlign:"left",//设置文本的水平对齐方式
  545. textPosition:"top",//设置文本的垂直位置
  546. textMargin:5,//设置条形码和文本之间的间距
  547. fontSize:15,//设置文本的大小
  548. margin:15//设置条形码周围的空白边距
  549. })
  550. });
  551. }
  552. })
  553. }
  554. }
  555. }
  556. })
  557. },
  558. handleCurrentChange(page) {
  559. this.isShow = true
  560. this.is_combination_print =false
  561. this.page = page
  562. this.getList()
  563. },
  564. handleSizeChange(limit) {
  565. this.isShow = true
  566. this.is_combination_print =false
  567. this.limit = limit
  568. this.getList()
  569. },
  570. changeDate() {
  571. this.page = 1
  572. this.limit = 10
  573. this.isShow = true
  574. this.is_combination_print =false
  575. this.getList()
  576. },changeItemTwo(){
  577. this.isShow = true
  578. this.is_combination_print =false
  579. this.page = 1
  580. this.limit = 10
  581. this.getList()
  582. },
  583. changeItem() {
  584. this.isShow = true
  585. this.is_combination_print =false
  586. this.page = 1
  587. this.limit = 10
  588. this.getList()
  589. },
  590. searchAction() {
  591. this.isShow = true
  592. this.is_combination_print =false
  593. this.page = 1
  594. this.limit = 10
  595. this.getList()
  596. },
  597. getList() {
  598. let params = {
  599. record_date: this.chargeDate,
  600. is_print: this.item_type,
  601. keyword: this.keywords,
  602. page: this.page,
  603. limit: this.limit,
  604. tube_color:this.tube_color,
  605. }
  606. GetLabelList(params).then(response => {
  607. if (response.data.state == 0) {
  608. this.$message.error(response.data.msg)
  609. return false
  610. } else {
  611. this.tableData = response.data.data.labels
  612. this.total = response.data.data.total
  613. for(var i = 0; i < this.tableData.length; i++){
  614. this.tableData[i]["ids"] = this.tableData[i].id
  615. if( this.tableData[i].team.id > 0 ){
  616. this.tableData[i]["project_ids"] = ""
  617. this.tableData[i]["team_ids"] = this.tableData[i].team.id
  618. }
  619. if( this.tableData[i].team.id == 0 ){
  620. this.tableData[i]["project_ids"] = this.tableData[i].project_id
  621. this.tableData[i]["team_ids"] = ""
  622. }
  623. }
  624. }
  625. })
  626. }, unique(array) {
  627. // res用来存储结果
  628. var res = []
  629. for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {
  630. for (var j = 0, resLen = res.length; j < resLen; j++) {
  631. if (array[i].patient_id === res[j].patient_id && array[i].tube_color === res[j].tube_color) {
  632. break
  633. }
  634. }
  635. // 如果array[i]是唯一的,那么执行完循环,j等于resLen
  636. if (j === resLen) {
  637. res.push(array[i])
  638. }
  639. }
  640. return res
  641. },uniqueTwo(array) {
  642. // res用来存储结果
  643. var res = []
  644. for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {
  645. for (var j = 0, resLen = res.length; j < resLen; j++) {
  646. if (array[i] === res[j]) {
  647. break
  648. }
  649. }
  650. // 如果array[i]是唯一的,那么执行完循环,j等于resLen
  651. if (j === resLen) {
  652. res.push(array[i])
  653. }
  654. }
  655. return res
  656. },
  657. getListTwo() {
  658. let params = {
  659. record_date: this.chargeDate,
  660. is_print: this.item_type,
  661. keyword: this.keywords,
  662. page: this.page,
  663. limit: this.limit,
  664. tube_color:this.tube_color_two,
  665. }
  666. getColorTubeLablePrints(params).then(response => {
  667. if (response.data.state == 0) {
  668. this.$message.error(response.data.msg)
  669. return false
  670. } else {
  671. this.tableDataTwo = []
  672. var tableDataOne = [] //有设置试管颜色的数组
  673. var tableDataTwo = [] //没有设置试管颜色的数组
  674. for(let i = 0; i < response.data.data.labels.length; i++){
  675. if(response.data.data.labels[i].team.tube_color == 0){
  676. tableDataTwo.push(response.data.data.labels[i])
  677. }
  678. }
  679. for(let i = 0; i < response.data.data.labels.length; i++){
  680. if(response.data.data.labels[i].team.tube_color > 0){
  681. tableDataOne.push(response.data.data.labels[i])
  682. }
  683. }
  684. for(var i = 0; i < tableDataTwo.length; i++){
  685. tableDataTwo[i]["ids"] = tableDataTwo[i].id
  686. if(tableDataTwo[i].team.id > 0 ){
  687. tableDataTwo[i]["team_ids"] = tableDataTwo[i].team.id
  688. tableDataTwo[i]["project_ids"] = ""
  689. }else if(tableDataTwo[i].team.id == 0 ){
  690. tableDataTwo[i]["team_ids"] = ""
  691. tableDataTwo[i]["project_ids"] = tableDataTwo[i].project_id
  692. }
  693. }
  694. var patients = []
  695. for(var i = 0; i < tableDataOne.length; i++){
  696. let obj = {
  697. patient_id:tableDataOne[i].patient_id,
  698. patient_name:tableDataOne[i].patient_name,
  699. tube_color: tableDataOne[i].team.tube_color,
  700. }
  701. patients.push(obj)
  702. }
  703. patients = this.unique(patients)
  704. for(let b = 0; b < patients.length; b++){
  705. var obj = {
  706. patient_id:patients[b].patient_id,
  707. patient_name:patients[b].patient_name,
  708. tube_color:patients[b].tube_color,
  709. record_date:"",
  710. doctor:"",
  711. project_name:"",
  712. ids:"",
  713. project_ids:"",
  714. team_ids:"",
  715. }
  716. for(let c = 0; c < tableDataOne.length;c++){
  717. if(patients[b].patient_id == tableDataOne[c].patient_id && patients[b].tube_color == tableDataOne[c].team.tube_color){
  718. obj["number"] = tableDataOne[c].number
  719. obj["team"] = tableDataOne[c].team
  720. obj.record_date = this.getTime(tableDataOne[c].record_date,'{y}-{m}-{d}')
  721. if(obj.project_name.length == 0){
  722. obj.project_name = tableDataOne[c].project_name
  723. }else{
  724. obj.project_name = obj.project_name +"," + tableDataOne[c].project_name
  725. }
  726. if (obj.ids.length == 0) {
  727. obj.ids = tableDataOne[c].id
  728. } else {
  729. obj.ids = obj.ids + "-" + tableDataOne[c].id
  730. }
  731. if(obj.team.id > 0) {
  732. if (obj.team_ids.length == 0) {
  733. obj.team_ids = tableDataOne[c].team.id
  734. } else {
  735. obj.team_ids = obj.team_ids + "-" + tableDataOne[c].team.id
  736. }
  737. }else if(obj.team.id == 0) {
  738. if(obj.project_ids.length == 0){
  739. obj.project_ids = tableDataOne[c].project_id
  740. }else{
  741. obj.project_ids = obj.project_ids +"-" + tableDataOne[c].project_id
  742. }
  743. }
  744. }
  745. }
  746. this.tableDataTwo.push(obj)
  747. }
  748. console.log(this.tableDataTwo)
  749. this.tableDataTwo = this.tableDataTwo.concat(tableDataTwo)
  750. console.log(this.tableDataTwo)
  751. this.total = response.data.data.total
  752. }
  753. })
  754. }
  755. },
  756. created() {
  757. this.getList()
  758. }, mounted() {
  759. },watch:{
  760. is_combination_print:function(){
  761. if(this.is_combination_print){
  762. this.isShow = false
  763. this.getListTwo()
  764. }else{
  765. this.isShow = true
  766. }
  767. }
  768. }
  769. }
  770. </script>