labelPrint.vue 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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:0px;">
  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 style="" 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:0px;">{{current_number}}</div>
  128. <div style="display:flex;">
  129. <div style="font-size:15px;padding-left:20px;">{{current_project_name}}</div>
  130. <div style="font-size:15px;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. console.log('vvvvvv',response.data.data);
  451. this.labelVisible = true
  452. if(response.data.data.labels.id > 0){
  453. console.log('内容1');
  454. this.current_ctime = row.ctime
  455. this.current_number = row.number
  456. this.current_project_name = row.project_name
  457. this.current_name = row.patient_name
  458. this.$nextTick(() => {
  459. JsBarcode('#barcode',response.data.data.labels.id, {
  460. format: 'CODE39',
  461. lineColor: '#000',
  462. background: '#EBEEF5',
  463. width: 3,
  464. height: 200,
  465. // width: 1,
  466. // height: 90,
  467. displayValue: false,
  468. fontOptions:"bold italic",//使文字加粗体或变斜体
  469. font:"fantasy",//设置文本的字体
  470. textAlign:"left",//设置文本的水平对齐方式
  471. textPosition:"top",//设置文本的垂直位置
  472. textMargin:5,//设置条形码和文本之间的间距
  473. fontSize:15,//设置文本的大小
  474. margin:0,//设置条形码周围的空白边距
  475. marginTop:0
  476. })
  477. });
  478. }else{
  479. console.log('内容2');
  480. let params = {
  481. is_combination_print:this.is_combination_print,
  482. patient_id: row.patient_id,
  483. ids: row.ids,
  484. team_ids: row.team_ids,
  485. project_ids:row.project_ids,
  486. doctor_id:row.doctor_id,
  487. is_team:0,
  488. record_date:this.chargeDate,
  489. }
  490. this.current_params = params
  491. console.log(this.current_params)
  492. if(!this.current_params.is_combination_print){
  493. if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
  494. this.current_params.is_team = 0
  495. }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
  496. this.current_params.is_team= 1
  497. }
  498. }else{
  499. this.current_params.is_team = 0
  500. }
  501. if(!this.isShow){
  502. createPrintLable(this.current_params).then(response => {
  503. if (response.data.state == 0) {
  504. this.$message.error(response.data.msg)
  505. return false
  506. } else {
  507. this.current_ctime = row.ctime
  508. this.current_number = row.number
  509. this.current_project_name = row.project_name
  510. this.current_name = row.patient_name
  511. this.$nextTick(() => {
  512. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  513. format: 'CODE39',
  514. lineColor: '#000',
  515. background: '#EBEEF5',
  516. width: 3,
  517. height: 200,
  518. displayValue: false,
  519. fontOptions:"bold italic",//使文字加粗体或变斜体
  520. font:"fantasy",//设置文本的字体
  521. textAlign:"left",//设置文本的水平对齐方式
  522. textPosition:"top",//设置文本的垂直位置
  523. textMargin:5,//设置条形码和文本之间的间距
  524. fontSize:15,//设置文本的大小
  525. margin:15//设置条形码周围的空白边距
  526. })
  527. });
  528. }
  529. })
  530. }else{
  531. createPrintLable(this.current_params).then(response => {
  532. if (response.data.state == 0) {
  533. this.$message.error(response.data.msg)
  534. return false
  535. } else {
  536. this.current_ctime = row.ctime
  537. this.current_number = row.number
  538. this.current_project_name = row.project_name
  539. this.current_name = row.patient_name
  540. this.$nextTick(() => {
  541. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  542. format: 'CODE39',
  543. lineColor: '#000',
  544. background: '#EBEEF5',
  545. width: 5,
  546. height: 300,
  547. displayValue: false,
  548. fontOptions:"bold italic",//使文字加粗体或变斜体
  549. font:"fantasy",//设置文本的字体
  550. textAlign:"left",//设置文本的水平对齐方式
  551. textPosition:"top",//设置文本的垂直位置
  552. textMargin:5,//设置条形码和文本之间的间距
  553. fontSize:15,//设置文本的大小
  554. margin:15//设置条形码周围的空白边距
  555. })
  556. });
  557. }
  558. })
  559. }
  560. }
  561. }
  562. })
  563. },
  564. handleCurrentChange(page) {
  565. this.isShow = true
  566. this.is_combination_print =false
  567. this.page = page
  568. this.getList()
  569. },
  570. handleSizeChange(limit) {
  571. this.isShow = true
  572. this.is_combination_print =false
  573. this.limit = limit
  574. this.getList()
  575. },
  576. changeDate() {
  577. this.page = 1
  578. this.limit = 10
  579. this.isShow = true
  580. this.is_combination_print =false
  581. this.getList()
  582. },changeItemTwo(){
  583. this.isShow = true
  584. this.is_combination_print =false
  585. this.page = 1
  586. this.limit = 10
  587. this.getList()
  588. },
  589. changeItem() {
  590. this.isShow = true
  591. this.is_combination_print =false
  592. this.page = 1
  593. this.limit = 10
  594. this.getList()
  595. },
  596. searchAction() {
  597. this.isShow = true
  598. this.is_combination_print =false
  599. this.page = 1
  600. this.limit = 10
  601. this.getList()
  602. },
  603. getList() {
  604. let params = {
  605. record_date: this.chargeDate,
  606. is_print: this.item_type,
  607. keyword: this.keywords,
  608. page: this.page,
  609. limit: this.limit,
  610. tube_color:this.tube_color,
  611. }
  612. GetLabelList(params).then(response => {
  613. if (response.data.state == 0) {
  614. this.$message.error(response.data.msg)
  615. return false
  616. } else {
  617. this.tableData = response.data.data.labels
  618. this.total = response.data.data.total
  619. for(var i = 0; i < this.tableData.length; i++){
  620. this.tableData[i]["ids"] = this.tableData[i].id
  621. if( this.tableData[i].team.id > 0 ){
  622. this.tableData[i]["project_ids"] = ""
  623. this.tableData[i]["team_ids"] = this.tableData[i].team.id
  624. }
  625. if( this.tableData[i].team.id == 0 ){
  626. this.tableData[i]["project_ids"] = this.tableData[i].project_id
  627. this.tableData[i]["team_ids"] = ""
  628. }
  629. }
  630. }
  631. })
  632. }, unique(array) {
  633. // res用来存储结果
  634. var res = []
  635. for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {
  636. for (var j = 0, resLen = res.length; j < resLen; j++) {
  637. if (array[i].patient_id === res[j].patient_id && array[i].tube_color === res[j].tube_color) {
  638. break
  639. }
  640. }
  641. // 如果array[i]是唯一的,那么执行完循环,j等于resLen
  642. if (j === resLen) {
  643. res.push(array[i])
  644. }
  645. }
  646. return res
  647. },uniqueTwo(array) {
  648. // res用来存储结果
  649. var res = []
  650. for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {
  651. for (var j = 0, resLen = res.length; j < resLen; j++) {
  652. if (array[i] === res[j]) {
  653. break
  654. }
  655. }
  656. // 如果array[i]是唯一的,那么执行完循环,j等于resLen
  657. if (j === resLen) {
  658. res.push(array[i])
  659. }
  660. }
  661. return res
  662. },
  663. getListTwo() {
  664. let params = {
  665. record_date: this.chargeDate,
  666. is_print: this.item_type,
  667. keyword: this.keywords,
  668. page: this.page,
  669. limit: this.limit,
  670. tube_color:this.tube_color_two,
  671. }
  672. getColorTubeLablePrints(params).then(response => {
  673. if (response.data.state == 0) {
  674. this.$message.error(response.data.msg)
  675. return false
  676. } else {
  677. this.tableDataTwo = []
  678. var tableDataOne = [] //有设置试管颜色的数组
  679. var tableDataTwo = [] //没有设置试管颜色的数组
  680. for(let i = 0; i < response.data.data.labels.length; i++){
  681. if(response.data.data.labels[i].team.tube_color == 0){
  682. tableDataTwo.push(response.data.data.labels[i])
  683. }
  684. }
  685. for(let i = 0; i < response.data.data.labels.length; i++){
  686. if(response.data.data.labels[i].team.tube_color > 0){
  687. tableDataOne.push(response.data.data.labels[i])
  688. }
  689. }
  690. for(var i = 0; i < tableDataTwo.length; i++){
  691. tableDataTwo[i]["ids"] = tableDataTwo[i].id
  692. if(tableDataTwo[i].team.id > 0 ){
  693. tableDataTwo[i]["team_ids"] = tableDataTwo[i].team.id
  694. tableDataTwo[i]["project_ids"] = ""
  695. }else if(tableDataTwo[i].team.id == 0 ){
  696. tableDataTwo[i]["team_ids"] = ""
  697. tableDataTwo[i]["project_ids"] = tableDataTwo[i].project_id
  698. }
  699. }
  700. var patients = []
  701. for(var i = 0; i < tableDataOne.length; i++){
  702. let obj = {
  703. patient_id:tableDataOne[i].patient_id,
  704. patient_name:tableDataOne[i].patient_name,
  705. tube_color: tableDataOne[i].team.tube_color,
  706. }
  707. patients.push(obj)
  708. }
  709. patients = this.unique(patients)
  710. for(let b = 0; b < patients.length; b++){
  711. var obj = {
  712. patient_id:patients[b].patient_id,
  713. patient_name:patients[b].patient_name,
  714. tube_color:patients[b].tube_color,
  715. record_date:"",
  716. doctor:"",
  717. project_name:"",
  718. ids:"",
  719. project_ids:"",
  720. team_ids:"",
  721. }
  722. for(let c = 0; c < tableDataOne.length;c++){
  723. if(patients[b].patient_id == tableDataOne[c].patient_id && patients[b].tube_color == tableDataOne[c].team.tube_color){
  724. obj["number"] = tableDataOne[c].number
  725. obj["team"] = tableDataOne[c].team
  726. obj.record_date = this.getTime(tableDataOne[c].record_date,'{y}-{m}-{d}')
  727. if(obj.project_name.length == 0){
  728. obj.project_name = tableDataOne[c].project_name
  729. }else{
  730. obj.project_name = obj.project_name +"," + tableDataOne[c].project_name
  731. }
  732. if (obj.ids.length == 0) {
  733. obj.ids = tableDataOne[c].id
  734. } else {
  735. obj.ids = obj.ids + "-" + tableDataOne[c].id
  736. }
  737. if(obj.team.id > 0) {
  738. if (obj.team_ids.length == 0) {
  739. obj.team_ids = tableDataOne[c].team.id
  740. } else {
  741. obj.team_ids = obj.team_ids + "-" + tableDataOne[c].team.id
  742. }
  743. }else if(obj.team.id == 0) {
  744. if(obj.project_ids.length == 0){
  745. obj.project_ids = tableDataOne[c].project_id
  746. }else{
  747. obj.project_ids = obj.project_ids +"-" + tableDataOne[c].project_id
  748. }
  749. }
  750. }
  751. }
  752. this.tableDataTwo.push(obj)
  753. }
  754. console.log(this.tableDataTwo)
  755. this.tableDataTwo = this.tableDataTwo.concat(tableDataTwo)
  756. console.log(this.tableDataTwo)
  757. this.total = response.data.data.total
  758. }
  759. })
  760. }
  761. },
  762. created() {
  763. this.getList()
  764. }, mounted() {
  765. },watch:{
  766. is_combination_print:function(){
  767. if(this.is_combination_print){
  768. this.isShow = false
  769. this.getListTwo()
  770. }else{
  771. this.isShow = true
  772. }
  773. }
  774. }
  775. }
  776. </script>