labelPrint.vue 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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" style="width: 500px;height: 250px;">
  119. <div style="display:flex;margin-bottom:0px;">
  120. <div style="margin-left:15px;">
  121. <div style="font-weight:bold;font-size:24px;" v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217&& $store.getters.xt_user.org.id != 10278&& $store.getters.xt_user.org.id != 10610&& $store.getters.xt_user.org.id != 0">C</div>
  122. <div>{{getTime(current_ctime,'{m}-{d} {h}:{i}')}}</div>
  123. <div style="font-size:18px;margin-left:20px;font-weight: bold;max-width: 100%;">{{current_name}}</div>
  124. </div>
  125. <img style="" v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217&& $store.getters.xt_user.org.id != 10278&& $store.getters.xt_user.org.id != 10610&& $store.getters.xt_user.org.id != 0" id="barcode">
  126. </div>
  127. <div style="margin-bottom:0px;">{{current_number}}</div>
  128. <div style="display:flex;flex-wrap: wrap; word-wrap: break-word; overflow-wrap: break-word;">
  129. <div style="font-size:18px;padding-left:20px;font-weight: bold;max-width:5cm;">{{current_project_name}}</div>
  130. </div>
  131. </div>
  132. </div>
  133. <div slot="footer" class="dialog-footer">
  134. <el-button @click="labelVisible = false">取 消</el-button>
  135. <el-button type="primary" @click="labelVisible = false">确 定</el-button>
  136. </div>
  137. </el-dialog>
  138. <el-dialog title="批量打印" :visible.sync="batchLabelVisible">
  139. <div>
  140. <el-row style="float:right;">
  141. <el-col :span="24">
  142. <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印
  143. </el-button>
  144. </el-col>
  145. </el-row>
  146. <div id="sign" class="signPrint">
  147. <div v-for="item in selecting_schs">
  148. <div style="display:flex;margin-bottom:10px;" >
  149. <div style="margin-left:15px;">
  150. <div style="font-weight:bold;font-size:24px;">C</div>
  151. <div>{{getTime(item.ctime,'{m}-{d}')}}</div>
  152. <div>{{getTime(item.ctime,'{h}:{i}')}}</div>
  153. </div>
  154. <img v-if="$store.getters.xt_user.org.id != 10138 && $store.getters.xt_user.org.id != 10217" id="barcode">
  155. </div>
  156. <div style="margin-bottom:5px;">{{item.number}}</div>
  157. <div style="display:flex;">
  158. <div style="font-size:24px;padding-left:20px;">{{item.project_name}}</div>
  159. <div style="font-size:24px;margin-left:20px;">{{item.patient_name}}</div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <div slot="footer" class="dialog-footer">
  165. <el-button @click="batchLabelVisible = false">取 消</el-button>
  166. <!-- <el-button type="primary" @click="labelVisible = false">确 定</el-button>-->
  167. </div>
  168. </el-dialog>
  169. </div>
  170. </template>
  171. <script>
  172. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  173. import { GetLabelList,getColorTubeLablePrints,createPrintLable,getPrintLable } from '@/api/his/his'
  174. import { uParseTime } from '@/utils/tools'
  175. import SignPrint from '../dialysis/signPrint'
  176. import JsBarcode from 'jsbarcode'
  177. import { getDictionaryDataConfig } from '@/utils/data'
  178. // import NewStatementPrint from './newStatementPrint'
  179. const moment = require('moment')
  180. export default {
  181. components: {
  182. SignPrint,
  183. BreadCrumb
  184. },
  185. data() {
  186. return {
  187. isShow:true,
  188. tube_color:"0",
  189. tube_color_two:"0",
  190. is_combination_print:false,
  191. current_ctime: 0,
  192. current_number: '',
  193. current_project_name: '',
  194. current_name: '',
  195. selecting_schs:[],
  196. labelVisible: false,
  197. crumbs: [
  198. { path: false, name: 'HIS工具' },
  199. { path: false, name: '标签打印' }
  200. ],
  201. detail_loading: false,
  202. tempArr: [],
  203. pos: 0,
  204. page: 1,
  205. limit: 10,
  206. total: 0,
  207. current_id: 0,
  208. sameRowArr: [],
  209. keywords: '',
  210. tableData: [],
  211. tableDataTwo: [],
  212. current_params:{},
  213. chargeDate: moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
  214. item_type: '0',
  215. items: [
  216. { id: 1, name: '已打印' },
  217. { id: 2, name: '未打印' }
  218. ],
  219. batchLabelVisible:false,
  220. }
  221. },
  222. methods: {
  223. printThree(){
  224. this.batchLabelVisible = true
  225. },
  226. printTwo(){
  227. if(this.selecting_schs.length == 0){
  228. this.$message.error("请选择需要组合打印的记录")
  229. return
  230. }
  231. let patient_ids = []
  232. for(let i = 0; i < this.selecting_schs.length; i++){
  233. patient_ids.push(this.selecting_schs[i].patient_id)
  234. }
  235. patient_ids = this.uniqueTwo(patient_ids)
  236. if(patient_ids.length != 0 && patient_ids.length > 1){
  237. this.$message.error("请选择同一患者打印")
  238. return
  239. }else{
  240. var name = ""
  241. var patient_name = ""
  242. var team_ids = ""
  243. var ids = ""
  244. var project_ids = ""
  245. for(let i = 0; i < this.selecting_schs.length; i++){
  246. if(ids.length == 0){
  247. ids = this.selecting_schs[i].id
  248. }else{
  249. ids = ids + "," + this.selecting_schs[i].id
  250. }
  251. patient_name = this.selecting_schs[0].patient_name
  252. if(name.length == 0){
  253. name = this.selecting_schs[i].project_name
  254. }else{
  255. name = name + "," + this.selecting_schs[i].project_name
  256. }
  257. if(team_ids.length == 0){
  258. if(this.selecting_schs[i].item_id > 0) {
  259. team_ids = this.selecting_schs[i].item_id
  260. }
  261. }else{
  262. if(this.selecting_schs[i].item_id > 0) {
  263. team_ids = team_ids + "," + this.selecting_schs[i].item_id
  264. }
  265. }
  266. if(project_ids.length == 0){
  267. console.log(this.selecting_schs[i])
  268. if(this.selecting_schs[i].item_id == 0) {
  269. project_ids = this.selecting_schs[i].project_id
  270. console.log(project_ids)
  271. }
  272. }else{
  273. if(this.selecting_schs[i].item_id == 0) {
  274. project_ids = project_ids + "," + this.selecting_schs[i].project_id
  275. console.log(project_ids)
  276. }
  277. }
  278. }
  279. console.log(project_ids)
  280. let params = {
  281. patient_id: patient_ids[0],
  282. ids: ids,
  283. record_date:this.chargeDate,
  284. }
  285. getPrintLable(params).then(response => {
  286. if (response.data.state == 0) {
  287. this.$message.error(response.data.msg)
  288. return false
  289. } else {
  290. this.labelVisible = true
  291. if(response.data.data.labels.id > 0){
  292. this.current_ctime = response.data.data.labels.ctime
  293. this.current_number = ""
  294. this.current_project_name =name
  295. this.current_name = patient_name
  296. this.$nextTick(() => {
  297. JsBarcode('#barcode',response.data.data.labels.id, {
  298. format: 'CODE39',
  299. lineColor: '#000',
  300. background: '#EBEEF5',
  301. width: 3,
  302. height: 100,
  303. displayValue: true,
  304. text:response.data.data.labels.id,
  305. fontOptions:"bold italic",//使文字加粗体或变斜体
  306. font:"fantasy",//设置文本的字体
  307. textAlign:"left",//设置文本的水平对齐方式
  308. textPosition:"top",//设置文本的垂直位置
  309. textMargin:5,//设置条形码和文本之间的间距
  310. fontSize:15,//设置文本的大小
  311. margin:15//设置条形码周围的空白边距
  312. })
  313. });
  314. }else{
  315. let params = {
  316. is_combination_print:this.is_combination_print,
  317. patient_id: patient_ids[0],
  318. ids:ids,
  319. team_ids:team_ids,
  320. project_ids:project_ids,
  321. doctor_id:0,
  322. is_team:0,
  323. record_date:this.chargeDate,
  324. }
  325. this.current_params = params
  326. console.log(this.current_params)
  327. if(!this.current_params.is_combination_print){
  328. if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
  329. this.current_params.is_team = 0
  330. }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
  331. this.current_params.is_team= 1
  332. }
  333. }else{
  334. this.current_params.is_team = 0
  335. }
  336. if(!this.isShow){
  337. createPrintLable(this.current_params).then(response => {
  338. if (response.data.state == 0) {
  339. this.$message.error(response.data.msg)
  340. return false
  341. } else {
  342. this.current_ctime = response.data.data.hlpsi.ctime
  343. this.current_number = ""
  344. this.current_project_name = name
  345. this.current_name = patient_name
  346. this.$nextTick(() => {
  347. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  348. format: 'CODE39',
  349. lineColor: '#000',
  350. background: '#EBEEF5',
  351. width: 3,
  352. height: 200,
  353. displayValue: false,
  354. fontOptions:"bold italic",//使文字加粗体或变斜体
  355. font:"fantasy",//设置文本的字体
  356. textAlign:"left",//设置文本的水平对齐方式
  357. textPosition:"top",//设置文本的垂直位置
  358. textMargin:5,//设置条形码和文本之间的间距
  359. fontSize:15,//设置文本的大小
  360. margin:15//设置条形码周围的空白边距
  361. })
  362. });
  363. }
  364. })
  365. }else{
  366. createPrintLable(this.current_params).then(response => {
  367. if (response.data.state == 0) {
  368. this.$message.error(response.data.msg)
  369. return false
  370. } else {
  371. this.current_ctime = response.data.data.hlpsi.ctime
  372. this.current_number =""
  373. this.current_project_name = name
  374. this.current_name = patient_name
  375. this.$nextTick(() => {
  376. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  377. format: 'CODE39',
  378. lineColor: '#000',
  379. background: '#EBEEF5',
  380. width: 5,
  381. height: 300,
  382. displayValue: false,
  383. fontOptions:"bold italic",//使文字加粗体或变斜体
  384. font:"fantasy",//设置文本的字体
  385. textAlign:"left",//设置文本的水平对齐方式
  386. textPosition:"top",//设置文本的垂直位置
  387. textMargin:5,//设置条形码和文本之间的间距
  388. fontSize:15,//设置文本的大小
  389. margin:15//设置条形码周围的空白边距
  390. })
  391. });
  392. }
  393. })
  394. }
  395. }
  396. }
  397. })
  398. }
  399. },
  400. handleSelectionChange(val) {
  401. this.selecting_schs = val
  402. console.log(this.selecting_schs)
  403. },
  404. getDictionaryDataConfig(module, filed_name) {
  405. return getDictionaryDataConfig(module, filed_name)
  406. },
  407. printAction: function() {
  408. const style = '@media print { .sign{width:500px;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;} }'
  409. printJS({
  410. printable: 'sign',
  411. type: 'html',
  412. documentTitle: ' ',
  413. style: style,
  414. scanStyles: false
  415. })
  416. // createPrintLable(this.current_params).then(response => {
  417. // if (response.data.state == 0) {
  418. // this.$message.error(response.data.msg)
  419. // return false
  420. // } else {
  421. // 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;} }'
  422. // printJS({
  423. // printable: 'sign',
  424. // type: 'html',
  425. // documentTitle: ' ',
  426. // style: style,
  427. // scanStyles: false
  428. // })
  429. // }
  430. // })
  431. },
  432. getTime(value, temp) {
  433. if (value != undefined) {
  434. return uParseTime(value, temp)
  435. }
  436. return ''
  437. },
  438. Print(row, index) {
  439. let params = {
  440. patient_id: row.patient_id,
  441. ids: row.ids,
  442. record_date:this.chargeDate,
  443. }
  444. getPrintLable(params).then(response => {
  445. if (response.data.state == 0) {
  446. this.$message.error(response.data.msg)
  447. return false
  448. } else {
  449. console.log('vvvvvv',response.data.data);
  450. this.labelVisible = true
  451. if(response.data.data.labels.id > 0){
  452. console.log('内容1');
  453. this.current_ctime = row.ctime
  454. this.current_number = row.number
  455. this.current_project_name = row.project_name
  456. this.current_name = row.patient_name
  457. this.$nextTick(() => {
  458. JsBarcode('#barcode',response.data.data.labels.id, {
  459. format: 'CODE39',
  460. lineColor: '#000',
  461. background: '#EBEEF5',
  462. width: 3,
  463. height: 200,
  464. // width: 1,
  465. // height: 90,
  466. displayValue: false,
  467. fontOptions:"bold italic",//使文字加粗体或变斜体
  468. font:"fantasy",//设置文本的字体
  469. textAlign:"left",//设置文本的水平对齐方式
  470. textPosition:"top",//设置文本的垂直位置
  471. textMargin:5,//设置条形码和文本之间的间距
  472. fontSize:15,//设置文本的大小
  473. margin:0,//设置条形码周围的空白边距
  474. marginTop:0
  475. })
  476. });
  477. }else{
  478. console.log('内容2');
  479. let params = {
  480. is_combination_print:this.is_combination_print,
  481. patient_id: row.patient_id,
  482. ids: row.ids,
  483. team_ids: row.team_ids,
  484. project_ids:row.project_ids,
  485. doctor_id:row.doctor_id,
  486. is_team:0,
  487. record_date:this.chargeDate,
  488. }
  489. this.current_params = params
  490. console.log(this.current_params)
  491. if(!this.current_params.is_combination_print){
  492. if(this.current_params.project_ids.toString().length > 0 && this.current_params.team_ids.toString().length == 0){
  493. this.current_params.is_team = 0
  494. }else if(this.current_params.project_ids.toString().length == 0 && this.current_params.team_ids.toString().length > 0){
  495. this.current_params.is_team= 1
  496. }
  497. }else{
  498. this.current_params.is_team = 0
  499. }
  500. if(!this.isShow){
  501. createPrintLable(this.current_params).then(response => {
  502. if (response.data.state == 0) {
  503. this.$message.error(response.data.msg)
  504. return false
  505. } else {
  506. this.current_ctime = row.ctime
  507. this.current_number = row.number
  508. this.current_project_name = row.project_name
  509. this.current_name = row.patient_name
  510. this.$nextTick(() => {
  511. JsBarcode('#barcode',response.data.data.hlpsi.id, {
  512. format: 'CODE39',
  513. lineColor: '#000',
  514. background: '#EBEEF5',
  515. width: 3,
  516. height: 200,
  517. displayValue: false,
  518. fontOptions:"bold italic",//使文字加粗体或变斜体
  519. font:"fantasy",//设置文本的字体
  520. textAlign:"left",//设置文本的水平对齐方式
  521. textPosition:"top",//设置文本的垂直位置
  522. textMargin:5,//设置条形码和文本之间的间距
  523. fontSize:15,//设置文本的大小
  524. margin:0,//设置条形码周围的空白边距
  525. marginTop:0
  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>