index.vue 151 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325
  1. <template>
  2. <div ref="appContainer" class="app-container">
  3. <div ref="myContainer" class="myContainer">
  4. <!-- 配方模板表 -->
  5. <div ref="template" class="template">
  6. <div class="recipeTemplate">
  7. <p>配方模板表</p>
  8. </div>
  9. <div class="search">
  10. <el-select v-model="table.parammaps.cattle_category_id" filterable placeholder="牲畜类别" class="filter-item" clearable>
  11. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  12. </el-select>
  13. <el-select v-model="table.parammaps.formula_type_id" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  14. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  15. </el-select>
  16. <el-select v-model="table.parammaps.data_source_id" filterable placeholder="来源" class="filter-item" style="width: 120px;" clearable>
  17. <el-option v-for="item in sourceList" :key="item.value" :label="item.label" :value="item.value" />
  18. </el-select>
  19. <el-select v-model="table.parammaps.is_show" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  20. <el-option v-for="item in enableList" :key="item.value" :label="item.label" :value="item.value" />
  21. </el-select>
  22. <div ref="selectInput" class="filter-item selectInput">
  23. <el-input v-model="table.parammaps.all" type="text" placeholder="请点击选择搜索条件" class="Input" />
  24. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  25. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  26. <ul v-if="arrowUp" class="selectUl">
  27. <li><a>配方名称</a><el-input v-model="table.parammaps.name" clearable style="width: 245px;" /></li>
  28. <li><a>备注</a><el-input v-model="table.parammaps.remarks" clearable style="width: 245px;" /></li>
  29. <li />
  30. <li>
  31. <div style="float: right;">
  32. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  33. <el-button class="miniPrimary" @click="handleSearch1">搜索</el-button>
  34. </div>
  35. </li>
  36. </ul>
  37. </div>
  38. <el-button class="successBorder" @click="handleSearch1">查询</el-button>
  39. <el-button class="successBorder" @click="handleRefresh1">重置</el-button>
  40. </div>
  41. <div class="operation">
  42. <el-button v-if="isAdd1" class="success" icon="el-icon-plus" @click="handleCreate1">新增</el-button>
  43. <el-upload style="float: right;" action="#" :http-request="httpRequest" :show-file-list="false" :on-change="handleChange" :before-upload="beforeAvatarUpload" multiple accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
  44. <el-button v-if="isImport1" class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  45. </el-upload>
  46. <el-dropdown style="float: right;margin-right: 10px;">
  47. <el-button v-if="isExport1" class="export" icon="el-icon-upload2">导出</el-button>
  48. <el-dropdown-menu slot="dropdown">
  49. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  50. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  51. </el-dropdown-menu>
  52. </el-dropdown>
  53. <el-button class="export" style="float: right;" @click="handleDistributeFormula">下发配方</el-button>
  54. </div>
  55. <div ref="table" class="table">
  56. <el-table
  57. :key="table.tableKey"
  58. v-loading="table.listLoading"
  59. element-loading-text="给我一点时间"
  60. :data="table.list"
  61. border
  62. fit
  63. highlight-current-row
  64. style="width: 98%;"
  65. :row-style="rowStyle"
  66. :cell-style="cellStyle"
  67. class="elTable table-fixed"
  68. :height="myheight1"
  69. @row-click="table1RowClick"
  70. @selection-change="handleSelectionChange"
  71. >
  72. <el-table-column type="selection" align="center" width="50" />
  73. <el-table-column label="序号" align="center" type="index" width="50px" />
  74. <el-table-column label="配方名称" min-width="90px" align="center">
  75. <template slot-scope="scope">
  76. <span v-if="scope.row.NoEdit">{{ scope.row.name }}</span>
  77. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.name" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="配方编码" min-width="130px" align="center">
  81. <template slot-scope="scope">
  82. <span v-if="scope.row.NoEdit">{{ scope.row.encode_number }}</span>
  83. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.encode_number" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" disabled maxlength="32" style="width:98%;padding:10px 0;" />
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="配方颜色" min-width="70px" align="center">
  87. <template slot-scope="scope">
  88. <el-color-picker v-model="scope.row.colour" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="scope.row.NoEdit" />
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="牲畜类别" min-width="130px" align="center">
  92. <template slot-scope="scope">
  93. <span v-if="scope.row.NoEdit">{{ scope.row.cattle_category_name }}</span>
  94. <el-select v-if="scope.row.Edit" v-model="scope.row.cattle_category_id" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType1">
  95. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  96. </el-select>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="配方类型" min-width="130px" align="center">
  100. <template slot-scope="scope">
  101. <span v-if="scope.row.NoEdit">{{ scope.row.formula_type_name }}</span>
  102. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.formula_type_id" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType1">
  103. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  104. </el-select>
  105. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.formula_type_id" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType1">
  106. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  107. </el-select>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="来源" min-width="90px" align="center" prop="data_source_name" />
  111. <el-table-column label="备注" min-width="90px" align="center">
  112. <template slot-scope="scope">
  113. <span v-if="scope.row.NoEdit">{{ scope.row.remarks }}</span>
  114. <el-input v-if="scope.row.Edit" v-model="scope.row.remarks" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="版本号" min-width="90px" align="center" prop="version">
  118. <template slot-scope="scope">
  119. <span>{{ scope.row.version }}</span>
  120. <!-- <span @click="clickNew(scope.row)" class="new">NEW</span> -->
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="使用牧场" min-width="90px" align="center" prop="pasture_name"/>
  124. <el-table-column label="是否启用" min-width="90px" align="center">
  125. <template slot-scope="scope">
  126. <el-switch v-model="scope.row.is_show" :disabled="scope.row.NoEdit==true && !isEnable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" @change="handleEnableChange1(scope.$index, scope.row,'show')" />
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="是否可修改" min-width="90px" align="center">
  130. <template slot-scope="scope">
  131. <el-switch v-model="scope.row.is_modify" :disabled="scope.row.NoEdit==true && !isModify1" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" @change="handleEnableChange1(scope.$index, scope.row,'modify')" />
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  135. <template slot-scope="{row}">
  136. <el-button v-if="row.NoEdit && isUsageOverview" icon="el-icon-tickets" class="miniSuccess" @click="handleRowUsageOverview(row)" />
  137. <span v-if="row.NoEdit && isRoleEdit && isUsageOverview" icon="el-icon-data-line" class="centerSpan">|</span>
  138. <el-button v-if="row.isCreate && isAdd1" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData1(row)" />
  139. <span v-if="row.isCreate && isAdd1" class="centerSpan">|</span>
  140. <el-button v-if="row.isCreate && isAdd1" class="minCancel" icon="el-icon-close" @click="createCancel1(row)" />
  141. <el-button v-if="row.isUpdate && isEdit1" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate1(row)" />
  142. <span v-if="row.isUpdate && isEdit1 && isDelete1" class="centerSpan">|</span>
  143. <el-button v-if="row.isUpdate && isDelete1" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete1(row)" />
  144. <el-button v-if="row.isUpdateSave && isEdit1" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData1(row)" />
  145. <span v-if="row.isUpdateSave && isEdit1" class="centerSpan">|</span>
  146. <el-button v-if="row.isUpdateSave && isEdit1" class="minCancel" icon="el-icon-close" @click="updateCancel1(row)" />
  147. <span v-if="row.NoEdit && isEdit1" icon="el-icon-data-line" class="centerSpan">|</span>
  148. <el-button v-if="row.NoEdit && isFormulaEvaluation" icon="el-icon-data-line" class="miniSuccess" @click="handleFormulationEvaluation(row)" />
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. </div>
  153. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;margin-bottom: 10px;font-size: 14px;">共{{ table.total }}条</span>
  154. </div>
  155. <!-- 配方详情表 -->
  156. <div v-if="isDetail" ref="detail" class="detail">
  157. <el-row :gutter="20">
  158. <el-col :span="8">
  159. <div class="search">
  160. <el-select v-model="table3.parammaps.pasture_id" style="width:100px;" filterable placeholder="牧场" class="filter-item" clearable>
  161. <el-option v-for="item in pastureList" :key="item.id" :label="item.name" :value="item.id" />
  162. </el-select>
  163. <el-date-picker v-model="table3.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  164. <el-button class="successBorder" @click="handleSearch3">查询</el-button>
  165. </div>
  166. <div class="table">
  167. <el-timeline>
  168. <el-timeline-item v-for="(item, index) in table3.list" color="#009A69" :key="index" :timestamp="item.timestamp">
  169. <span style="font-size:14px;">{{item.pasture_name}}</span><br/>
  170. <span style="font-size:12px;">{{item.modify_time}}</span><br/>
  171. <span style="font-size:12px;">{{item.modify_detail}}</span>
  172. </el-timeline-item>
  173. </el-timeline>
  174. </div>
  175. </el-col>
  176. <el-col :span="16">
  177. <div class="recipeTemplate">
  178. <p>配方详情表</p>
  179. </div>
  180. <div class="operation" style="margin-bottom: 10px;">
  181. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-plus" class="success" @click="handleCreate2">新增</el-button>
  182. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-delete" class="danger" @click="form_delete2">删除</el-button>
  183. <el-button v-if="isRoleEdit" style="float: left;" class="success" icon="el-icon-takeaway-box" @click="handleSyntheticPremix">合成预混料</el-button>
  184. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  185. <div v-else style="float: left;margin-left: 10px;">
  186. <el-button icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  187. <el-button icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  188. </div>
  189. <el-button class="hide" @click="handleCloseTable2">隐藏</el-button>
  190. <el-button v-if="isEnlarge" class="hide2" @click="handleEnlarge">放大</el-button>
  191. <el-button v-else class="hide2" @click="handleNarrow">缩小</el-button>
  192. </div>
  193. <div class="search">
  194. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  195. <el-input v-model="table2.parammaps.all" type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  196. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  197. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  198. <ul v-if="arrowUp2" class="selectUl">
  199. <li>
  200. <a style="width: 130px;">饲料名称</a>
  201. <el-select v-model="table2.parammaps.forage_name" filterable clearable placeholder="" style="width:190px;">
  202. <el-option v-for="item in feedNameList" :key="item.id" :label="item.name" :value="item.name" />
  203. </el-select>
  204. </li>
  205. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.parammaps.forage_group_name" style="width: 190px;" /></li>
  206. <li><a style="width: 130px;">重量</a><el-input v-model="table2.parammaps.weight" style="width: 190px;" /></li>
  207. <li>
  208. <a style="width: 130px;">搅拌延时</a>
  209. <el-select v-model="table2.parammaps.stir_delay" filterable placeholder="" style="width:190px;" clearable>
  210. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  211. </el-select>
  212. </li>
  213. <li>
  214. <a style="width: 130px;">是否锁定牛头数比例</a>
  215. <el-select v-model="table2.parammaps.is_lock_cow_count_ratio" placeholder="" style="width:190px;" clearable>
  216. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  217. </el-select>
  218. </li>
  219. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.parammaps.sort" style="width: 190px;" /></li>
  220. <li>
  221. <div style="float: right;">
  222. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  223. <el-button class="miniPrimary" @click="form_search2">搜索</el-button>
  224. </div>
  225. </li>
  226. </ul>
  227. </div>
  228. <el-button class="successBorder" @click="form_search2">查询</el-button>
  229. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  230. </div>
  231. <div v-if="isEnlarge" class="table2">
  232. <el-table
  233. id="table2"
  234. ref="table2"
  235. :key="table2.tableKey"
  236. v-loading="table2.listLoading"
  237. element-loading-text="给我一点时间"
  238. :data="table2.list"
  239. border
  240. fit
  241. highlight-current-row
  242. style="width: 98%;"
  243. :row-style="rowStyle"
  244. :cell-style="cellStyle"
  245. class="elTable"
  246. row-key="id"
  247. show-summary
  248. :max-height="220"
  249. :summary-method="getSummaries"
  250. @selection-change="handleSelectionChange2"
  251. @cell-dblclick="celldblclick"
  252. >
  253. <el-table-column type="selection" width="50" />
  254. <el-table-column label="序号" align="center" type="index" width="50px" />
  255. <el-table-column label="饲料组" min-width="120px" align="center">
  256. <template slot-scope="scope">
  257. <span v-if="scope.row.groupNoEdit">{{ scope.row.forage_group_name }}</span>
  258. <el-input v-if="scope.row.groupEdit" v-model="scope.row.forage_group_name" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  259. </template>
  260. </el-table-column>
  261. <el-table-column label="饲料名称" min-width="120px" align="center">
  262. <template slot-scope="scope">
  263. <span v-if="scope.row.NoEdit">{{ scope.row.forage_name }}</span>
  264. <el-select v-if="scope.row.Edit" v-model="scope.row.forage_id" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  265. <el-option v-for="item in feedNameList" :key="item.id" :label="item.name" :value="item.id" />
  266. </el-select>
  267. </template>
  268. </el-table-column>
  269. <el-table-column label="重量(KG)" prop="fweight" width="120px" align="center">
  270. <template slot-scope="scope">
  271. <span v-if="scope.row.NoEdit">{{ scope.row.weight }}</span>
  272. <el-input v-if="scope.row.Edit" v-model="scope.row.weight" placeholder="重量" step="0.0001" type="number" style="width:95%;padding:10px 0;" />
  273. </template>
  274. </el-table-column>
  275. <el-table-column label="搅拌延时(min)" min-width="80px" align="center">
  276. <template slot-scope="scope">
  277. <span v-if="scope.row.NoEdit">{{ scope.row.stir_delay }}</span>
  278. <el-select v-if="scope.row.Edit" v-model="scope.row.stir_delay" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  279. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  280. </el-select>
  281. </template>
  282. </el-table-column>
  283. <el-table-column label="允许延时偏差(min)" min-width="80px" align="center">
  284. <template slot-scope="scope">
  285. <span v-if="scope.row.NoEdit">{{ scope.row.allow_error }}</span>
  286. <el-input v-if="scope.row.Edit" v-model="scope.row.allow_error" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" />
  287. </template>
  288. </el-table-column>
  289. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="80px" align="center">
  290. <template slot-scope="scope">
  291. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  292. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  293. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  294. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  295. </el-select>
  296. </template>
  297. </el-table-column>
  298. <el-table-column label="顺序" min-width="70px" align="center">
  299. <template slot-scope="scope">
  300. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  301. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  302. </template>
  303. </el-table-column>
  304. <el-table-column label="是否可修改" min-width="90px" align="center">
  305. <template slot-scope="scope">
  306. <el-switch v-model="scope.row.is_modify" :disabled="scope.row.NoEdit==true && !isModify2" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" @change="handleEnableChange2(scope.$index, scope.row,'modify')" />
  307. </template>
  308. </el-table-column>
  309. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  310. <template slot-scope="{row}">
  311. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData2(row)" />
  312. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  313. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  314. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  315. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  316. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  317. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData2(row)" />
  318. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  319. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel2(row)" />
  320. <span v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" class="centerSpan">|</span>
  321. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" icon="el-icon-connection" class="miniSuccess" @click="handleSplitPremix(row)" />
  322. </template>
  323. </el-table-column>
  324. </el-table>
  325. </div>
  326. <div v-else class="table2">
  327. <el-table
  328. id="table2"
  329. ref="mytable2"
  330. :key="table2.tableKey"
  331. v-loading="table2.listLoading"
  332. element-loading-text="给我一点时间"
  333. :data="table2.list"
  334. border
  335. fit
  336. highlight-current-row
  337. style="width: 98%;"
  338. :row-style="rowStyle"
  339. :cell-style="cellStyle"
  340. class="elTable"
  341. row-key="id"
  342. show-summary
  343. :max-height="enlargeHeight"
  344. :summary-method="getSummaries"
  345. @selection-change="handleSelectionChange2"
  346. @cell-dblclick="celldblclick"
  347. >
  348. <el-table-column type="selection" width="50" />
  349. <el-table-column label="序号" align="center" type="index" width="50px" />
  350. <el-table-column label="饲料组" min-width="120px" align="center">
  351. <template slot-scope="scope">
  352. <span v-if="scope.row.groupNoEdit">{{ scope.row.forage_group_name }}</span>
  353. <el-input v-if="scope.row.groupEdit" v-model="scope.row.forage_group_name" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  354. </template>
  355. </el-table-column>
  356. <el-table-column label="饲料名称" min-width="120px" align="center">
  357. <template slot-scope="scope">
  358. <span v-if="scope.row.NoEdit">{{ scope.row.forage_name }}</span>
  359. <el-select v-if="scope.row.Edit" v-model="scope.row.forage_id" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  360. <el-option v-for="item in feedNameList" :key="item.id" :label="item.name" :value="item.id" />
  361. </el-select>
  362. </template>
  363. </el-table-column>
  364. <el-table-column label="重量(KG)" prop="fweight" width="120px" align="center">
  365. <template slot-scope="scope">
  366. <span v-if="scope.row.NoEdit">{{ scope.row.weight }}</span>
  367. <el-input v-if="scope.row.Edit" v-model="scope.row.weight" placeholder="重量" step="0.0001" type="number" style="width:95%;padding:10px 0;" />
  368. </template>
  369. </el-table-column>
  370. <el-table-column label="搅拌延时(min)" min-width="80px" align="center">
  371. <template slot-scope="scope">
  372. <span v-if="scope.row.NoEdit">{{ scope.row.stir_delay }}</span>
  373. <el-select v-if="scope.row.Edit" v-model="scope.row.stir_delay" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  374. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  375. </el-select>
  376. </template>
  377. </el-table-column>
  378. <el-table-column label="允许延时偏差(min)" min-width="80px" align="center">
  379. <template slot-scope="scope">
  380. <span v-if="scope.row.NoEdit">{{ scope.row.allow_error }}</span>
  381. <el-input v-if="scope.row.Edit" v-model="scope.row.allow_error" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" />
  382. </template>
  383. </el-table-column>
  384. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="80px" align="center">
  385. <template slot-scope="scope">
  386. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  387. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  388. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  389. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  390. </el-select>
  391. </template>
  392. </el-table-column>
  393. <el-table-column label="顺序" min-width="70px" align="center">
  394. <template slot-scope="scope">
  395. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  396. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)"/>
  397. </template>
  398. </el-table-column>
  399. <el-table-column label="是否可修改" min-width="90px" align="center">
  400. <template slot-scope="scope">
  401. <el-switch v-model="scope.row.is_modify" :disabled="scope.row.NoEdit==true && !isModify2" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" @change="handleEnableChange2(scope.$index, scope.row,'modify')" />
  402. </template>
  403. </el-table-column>
  404. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  405. <template slot-scope="{row}">
  406. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData2(row)" />
  407. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  408. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  409. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  410. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  411. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  412. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData2(row)" />
  413. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  414. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel2(row)" />
  415. <span v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" class="centerSpan">|</span>
  416. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" icon="el-icon-connection" class="miniSuccess" @click="handleSplitPremix(row)" />
  417. </template>
  418. </el-table-column>
  419. </el-table>
  420. </div>
  421. </el-col>
  422. </el-row>
  423. </div>
  424. </div>
  425. <!-- 下发配方 -->
  426. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="distributeFormula.dialogFormVisible" :close-on-click-modal="false" width="90%">
  427. <template slot="title">
  428. <div class="avue-crud__dialog__header">
  429. <span class="el-dialog__title">
  430. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  431. {{ textMap[distributeFormula.dialogStatus] }}
  432. </span>
  433. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  434. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  435. <svg-icon v-else icon-class="fullscreen" />
  436. </div>
  437. </div>
  438. </template>
  439. <div class="dialogMinHeight" style="overflow-y: auto;margin-bottom: 0px;overflow-x: hidden;">
  440. <div ref="distributeFormulaDialog" class="distributeFormulaDialog">
  441. <div class="search">
  442. <el-input v-model="distributeFormula.table.parammaps.name" placeholder="请输入牧场名称搜索" style="width: 245px;" />
  443. <el-button class="successBorder" @click="handleDistributeFormulaSearch" style="margin-left:10px;">查询</el-button>
  444. <el-button class="successBorder" @click="handleDistributeFormulaRefresh" style="margin-left:10px;">重置</el-button>
  445. </div>
  446. <div class="table">
  447. <el-table
  448. :key="distributeFormula.table.tableKey"
  449. v-loading="distributeFormula.table.listLoading"
  450. element-loading-text="给我一点时间"
  451. :data="distributeFormula.table.list"
  452. border
  453. fit
  454. highlight-current-row
  455. style="width: 98%;"
  456. :row-style="rowStyle"
  457. :cell-style="cellStyle"
  458. class="elTable table-fixed"
  459. @selection-change="handleSelectionDistributeFormula">
  460. >
  461. <el-table-column type="selection" width="55" />
  462. <el-table-column label="序号" align="center" type="index" width="50px" />
  463. <el-table-column label="牧场名称" min-width="130px" align="center" prop="name" />
  464. <el-table-column label="负责人姓名" min-width="90px" align="center" prop="manager_user" />
  465. <el-table-column label="手机号" min-width="90px" align="center" prop="manager_phone" />
  466. <el-table-column label="牧场地址" min-width="90px" align="center" prop="address" />
  467. </el-table>
  468. </div>
  469. </div>
  470. </div>
  471. <div slot="footer" class="dialog-footer">
  472. <el-button class="cancelClose" @click="distributeFormula.dialogFormVisible = false; ">关闭</el-button>
  473. <el-button class="save" :disabled="isokDisable || distributeFormula.selectionList.length == 0" @click="distributeFormulaData()">确认</el-button>
  474. </div>
  475. </el-dialog>
  476. <!-- 配方模板表 -->
  477. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  478. <template slot="title">
  479. <div class="avue-crud__dialog__header">
  480. <span class="el-dialog__title">
  481. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  482. {{ textMap[template.dialogStatus] }}
  483. </span>
  484. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  485. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  486. <svg-icon v-else icon-class="fullscreen" />
  487. </div>
  488. </div>
  489. </template>
  490. <div class="dialogMinHeight" style="overflow-y: auto;margin-bottom: 0px;overflow-x: hidden;">
  491. <div ref="templateDialog" class="templateDialog">
  492. <div class="recipeTemplate">
  493. <p>配方模板表</p>
  494. </div>
  495. <div class="operation1">
  496. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  497. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  498. </div>
  499. <div class="search">
  500. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  501. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  502. </el-select>
  503. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  504. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  505. </el-select>
  506. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="margin-left:10px;width: 120px;" clearable>
  507. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  508. </el-select>
  509. <div ref="selectInput" class="filter-item selectInput">
  510. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  511. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  512. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  513. <ul v-if="arrowUp" class="selectUl">
  514. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  515. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  516. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  517. <li>
  518. <div style="float: right;">
  519. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  520. <el-button class="miniPrimary" @click="handleDialogSearch">搜索</el-button>
  521. </div>
  522. </li>
  523. </ul>
  524. </div>
  525. <el-button class="successBorder" @click="handleDialogSearch" style="margin-left:10px;">查询</el-button>
  526. <el-button class="successBorder" @click="handleDialogRefresh" style="margin-left:10px;">重置</el-button>
  527. </div>
  528. <div class="table">
  529. <el-table
  530. :key="template.table.tableKey"
  531. v-loading="template.table.listLoading"
  532. element-loading-text="给我一点时间"
  533. :data="template.table.list"
  534. border
  535. fit
  536. highlight-current-row
  537. style="width: 98%;"
  538. :row-style="rowStyle"
  539. :height="myheight2"
  540. :cell-style="cellStyle"
  541. class="elTable table-fixed"
  542. @row-click="tableRowClickDialog"
  543. >
  544. <el-table-column v-if="template.dialogStatus == 'RecipeRecord'" label="序号" align="center" type="index" width="50px" />
  545. <el-table-column v-else label="序号" align="center" type="index" width="50px">
  546. <template slot-scope="scope">
  547. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  548. </template>
  549. </el-table-column>
  550. <el-table-column label="配方名称" min-width="130px" align="center">
  551. <template slot-scope="scope">
  552. <span>{{ scope.row.tname }}</span>
  553. </template>
  554. </el-table-column>
  555. <el-table-column label="配方编码" min-width="90px" align="center">
  556. <template slot-scope="scope">
  557. <span>{{ scope.row.tcode }}</span>
  558. </template>
  559. </el-table-column>
  560. <el-table-column label="配方颜色" min-width="110px" align="center">
  561. <template slot-scope="scope">
  562. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" />
  563. </template>
  564. </el-table-column>
  565. <el-table-column label="牲畜类别" min-width="110px" align="center">
  566. <template slot-scope="scope">
  567. <span>{{ scope.row.ccname }}</span>
  568. </template>
  569. </el-table-column>
  570. <el-table-column label="配方类型" min-width="110px" align="center">
  571. <template slot-scope="scope">
  572. <span>{{ scope.row.fttype }}</span>
  573. </template>
  574. </el-table-column>
  575. <el-table-column label="来源" min-width="90px" align="center">
  576. <template slot-scope="scope">
  577. <span>{{ scope.row.source }}</span>
  578. </template>
  579. </el-table-column>
  580. <el-table-column label="备注" min-width="90px" align="center">
  581. <template slot-scope="scope">
  582. <span>{{ scope.row.remark }}</span>
  583. </template>
  584. </el-table-column>
  585. <el-table-column label="版本号" min-width="90px" align="center">
  586. <template slot-scope="scope">
  587. <span>{{ scope.row.version }}</span>
  588. </template>
  589. </el-table-column>
  590. <el-table-column label="版本时间" min-width="90px" align="center">
  591. <template slot-scope="scope">
  592. <span>{{ scope.row.versiontime }}</span>
  593. </template>
  594. </el-table-column>
  595. <el-table-column label="是否启用" min-width="90px" align="center">
  596. <template slot-scope="scope">
  597. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  598. </template>
  599. </el-table-column>
  600. </el-table>
  601. </div>
  602. </div>
  603. <div v-if="isDetailDialog" id="detailDialog2" ref="detailDialog2" class="detailDialog" style="margin-top: 30px;height: 200px;overflow-y: auto;overflow-x: hidden;">
  604. <div class="recipeTemplate">
  605. <p>配方详情表</p>
  606. </div>
  607. <div class="operation" >
  608. <div ref="selectInput2" class="filter-item selectInput">
  609. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  610. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  611. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  612. <ul v-if="arrowUp2" class="selectUl">
  613. <li>
  614. <a style="width: 130px;">饲料名称</a>
  615. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  616. <el-option v-for="item in feedNameList" :key="item.id" :label="item.name" :value="item.name" />
  617. </el-select>
  618. </li>
  619. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  620. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  621. <li>
  622. <a style="width: 130px;">搅拌延时</a>
  623. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  624. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  625. </el-select>
  626. </li>
  627. <li>
  628. <a style="width: 130px;">是否锁定牛头数比例</a>
  629. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  630. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  631. </el-select>
  632. </li>
  633. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  634. <li>
  635. <div style="float: right;">
  636. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  637. <el-button class="miniPrimary" @click="handleDialogSearch2">搜索</el-button>
  638. </div>
  639. </li>
  640. </ul>
  641. </div>
  642. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  643. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  644. <el-button class="hide" @click="handleDialogCloseTable2">隐藏</el-button>
  645. </div>
  646. <div class="table2">
  647. <el-table
  648. id="templateTable2"
  649. :key="template.table2.tableKey"
  650. v-loading="template.table2.listLoading"
  651. element-loading-text="给我一点时间"
  652. :data="template.table2.list"
  653. border
  654. fit
  655. highlight-current-row
  656. style="width: 98%;"
  657. :summary-method="getTemplateTable2Summaries"
  658. show-summary
  659. :row-style="rowStyle"
  660. :cell-style="cellStyle"
  661. class="elTable table-fixed"
  662. row-key="id"
  663. >
  664. <el-table-column label="饲料组" min-width="130px" align="center">
  665. <template slot-scope="scope">
  666. <span>{{ scope.row.feedgroup }}</span>
  667. </template>
  668. </el-table-column>
  669. <el-table-column label="饲料名称" min-width="130px" align="center">
  670. <template slot-scope="scope">
  671. <span>{{ scope.row.fname }}</span>
  672. </template>
  673. </el-table-column>
  674. <el-table-column label="重量(KG)" prop="fweight" min-width="200px" align="center">
  675. <template slot-scope="scope">
  676. <span>{{ scope.row.fweight }}</span>
  677. </template>
  678. </el-table-column>
  679. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  680. <template slot-scope="scope">
  681. <span>{{ scope.row.autosecondname }}</span>
  682. </template>
  683. </el-table-column>
  684. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  685. <template slot-scope="scope">
  686. <span v-if="scope.row.islockcount == '0'">否</span>
  687. <span v-if="scope.row.islockcount == '1'">是</span>
  688. </template>
  689. </el-table-column>
  690. <el-table-column label="顺序" min-width="130px" align="center">
  691. <template slot-scope="scope">
  692. <span>{{ scope.row.sort }}</span>
  693. </template>
  694. </el-table-column>
  695. </el-table>
  696. </div>
  697. </div>
  698. </div>
  699. <div slot="footer" class="dialog-footer">
  700. <el-button class="cancelClose cancelClose1" @click="template.dialogFormVisible = false; ">关闭</el-button>
  701. </div>
  702. </el-dialog>
  703. <!-- 合成预混料 -->
  704. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  705. <template slot="title">
  706. <div class="avue-crud__dialog__header">
  707. <span class="el-dialog__title">
  708. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  709. {{ textMap[detail.dialogStatus] }}
  710. </span>
  711. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  712. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  713. <svg-icon v-else icon-class="fullscreen" />
  714. </div>
  715. </div>
  716. </template>
  717. <div class="detailDialog">
  718. <h2>饲料</h2>
  719. <div class="table1">
  720. <el-table
  721. :key="detail.tableKey"
  722. v-loading="detail.listLoading"
  723. element-loading-text="给我一点时间"
  724. :data="detail.list"
  725. fit
  726. highlight-current-row
  727. style="width: 100%;"
  728. :row-style="rowStyle"
  729. :cell-style="cellStyle"
  730. class="elTable table-fixed"
  731. show-summary
  732. >
  733. <el-table-column label="序号" align="center" type="index" width="50px" />
  734. <el-table-column label="饲料名称" min-width="130px" align="center">
  735. <template slot-scope="scope">
  736. <span>{{ scope.row.forage_name }}</span>
  737. </template>
  738. </el-table-column>
  739. <el-table-column prop="weight" label="重量(KG)" />
  740. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  741. <template slot-scope="scope">
  742. <span>{{ scope.row.stir_delay }}</span>
  743. </template>
  744. </el-table-column>
  745. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  746. <template slot-scope="scope">
  747. <span v-if="scope.row.islockcount == '0'">否</span>
  748. <span v-if="scope.row.islockcount == '1'">是</span>
  749. </template>
  750. </el-table-column>
  751. <el-table-column label="顺序" min-width="110px" align="center">
  752. <template slot-scope="scope">
  753. <span>{{ scope.row.sort }}</span>
  754. </template>
  755. </el-table-column>
  756. </el-table>
  757. </div>
  758. <h2>合成预混料</h2>
  759. <div class="table2" style="margin-bottom: 50px;">
  760. <el-table
  761. :key="detail.tableKey2"
  762. v-loading="detail.listLoading2"
  763. element-loading-text="给我一点时间"
  764. :data="detail.list2"
  765. border
  766. fit
  767. highlight-current-row
  768. style="width: 100%;"
  769. :row-style="rowStyle"
  770. :cell-style="cellStyle"
  771. class="elTable table-fixed"
  772. >
  773. <el-table-column label="配方名称" min-width="130px" align="center">
  774. <template slot-scope="scope">
  775. <el-input v-model="scope.row.name" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  776. </template>
  777. </el-table-column>
  778. <el-table-column label="配方颜色" min-width="130px" align="center">
  779. <template slot-scope="scope">
  780. <el-color-picker v-model="scope.row.colour" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="detail.disabled" />
  781. </template>
  782. </el-table-column>
  783. <el-table-column label="牲畜类别" min-width="130px" align="center">
  784. <template slot-scope="scope">
  785. <el-select v-model="scope.row.cattle_category_id" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  786. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  787. </el-select>
  788. </template>
  789. </el-table-column>
  790. <el-table-column label="配方类型" min-width="110px" align="center">
  791. <template slot-scope="scope">
  792. <span>{{ scope.row.formula_type_name }}</span>
  793. </template>
  794. </el-table-column>
  795. <el-table-column label="来源" min-width="110px" align="center">
  796. <template slot-scope="scope">
  797. <span>{{ scope.row.data_source_name }}</span>
  798. </template>
  799. </el-table-column>
  800. <el-table-column label="备注" min-width="130px" align="center">
  801. <template slot-scope="scope">
  802. <el-input v-model="scope.row.remarks" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  803. </template>
  804. </el-table-column>
  805. <el-table-column label="是否启用" min-width="130px" align="center">
  806. <template slot-scope="scope">
  807. <el-switch v-model="scope.row.is_show" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" :disabled="detail.disabled" />
  808. </template>
  809. </el-table-column>
  810. </el-table>
  811. </div>
  812. <div slot="footer" class="dialog-footer">
  813. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  814. <el-button class="save" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  815. </div>
  816. </div>
  817. </el-dialog>
  818. <!-- 历史记录 -->
  819. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  820. <div class="historyRecord">
  821. <keep-alive>
  822. <component :is="historyRecord.myComponent" ref="historyRecord" />
  823. </keep-alive>
  824. </div>
  825. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  826. <el-button class="cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  827. </div>
  828. </el-dialog>
  829. <!-- 行内配方记录 -->
  830. <el-dialog :title="textMap[usageOverview.dialogStatus]" :destroy-on-close="true" :visible.sync="usageOverview.dialogFormVisible" :close-on-click-modal="false" width="90%">
  831. <div class="usageOverview">
  832. <div class="search">
  833. <el-date-picker ref="inputDatetime" v-model="usageOverview.getdataListParm.parammaps.inputDatetime" class="filter-item inputDatetime" type="daterange" style="width: 250px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
  834. <el-button class="successBorder" @click="handleRowUsageOverviewSearch">查询</el-button>
  835. </div>
  836. <div class="table">
  837. <el-table
  838. :key="usageOverview.tableKey"
  839. v-loading="usageOverview.listLoading"
  840. element-loading-text="给我一点时间"
  841. :data="usageOverview.list"
  842. border
  843. highlight-current-row
  844. style="width: 100%;"
  845. :row-style="rowStyle"
  846. :cell-style="cellStyle"
  847. class="elTable table-fixed"
  848. >
  849. <el-table-column label="序号" align="center" width="50px" type="index" />
  850. <!-- <el-table-column label="序号" width="60px" align="center" prop="sort" /> -->
  851. <el-table-column label="牧场名称" min-width="100px" align="center" prop="pasture_name" />
  852. <el-table-column label="混料准确率(%)" min-width="100px" align="center" prop="mixed_fodder_accurate_ratio" />
  853. <el-table-column label="混料正确率(%)" min-width="100px" align="center" prop="mixed_fodder_correct_ratio" />
  854. <el-table-column label="撒料准确率(%)" min-width="100px" align="center" prop="sprinkle_fodder_accurate_ratio" />
  855. <el-table-column label="撒料正确率(%)" min-width="100px" align="center" prop="sprinkle_fodder_correct_ratio" />
  856. <el-table-column label="搅拌时间(分钟)" min-width="100px" align="center" prop="add_feed_time" />
  857. <el-table-column label="搅拌延时(分钟)" min-width="100px" align="center" prop="sprinkle_time" />
  858. <el-table-column label="撒料时间(分钟)" min-width="100px" align="center" prop="stir_time" />
  859. <el-table-column label="最近修改配方时间" min-width="100px" align="center" prop="last_edit_time" />
  860. <!-- <el-table-column label="下发时间" min-width="100px" align="center" prop="datetime1" /> -->
  861. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  862. <template slot-scope="{row}">
  863. <a class="correcting" size="mini" style="width: 80px;" @click="handle_feedingefficiency(row)">饲喂效率</a>
  864. <span v-if="isCanceldistributingformula" icon="el-icon-data-line" class="centerSpan">|</span>
  865. <a v-if="isCanceldistributingformula" class="correcting" size="mini" style="width: 80px;" @click="handle_canceldistributingformula(row)">取消下发配方</a>
  866. </template>
  867. </el-table-column>
  868. </el-table>
  869. </div>
  870. </div>
  871. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  872. <el-button class="cancelClose1" @click="usageOverview.dialogFormVisible = false; ">关闭</el-button>
  873. </div>
  874. </el-dialog>
  875. <el-dialog :title="textMap[feedingEfficiency.dialogStatus]" :destroy-on-close="true" :visible.sync="feedingEfficiency.dialogFormVisible" :close-on-click-modal="false" width="50%">
  876. <div class="content">
  877. <div><span class="title">实际牛头数</span><span class="num">{{feedingEfficiency.data.actual_number_of_cattle}}</span></div>
  878. <div><span class="title">应混料量(kg)</span><span class="num">{{feedingEfficiency.data.amount_to_be_mixed}}</span></div>
  879. <div><span class="title">实际混料量(kg)</span><span class="num">{{feedingEfficiency.data.actual_mixed_volume}}</span></div>
  880. <div><span class="title">撒料量(kg)</span><span class="num">{{feedingEfficiency.data.sprinkle_volume}}</span></div>
  881. <div><span class="title">转投剩料量(kg)</span><span class="num">{{feedingEfficiency.data.leftover_material}}</span></div>
  882. <div><span class="title">今日剩料量(kg)</span><span class="num">{{feedingEfficiency.data.today_leftovers}}</span></div>
  883. <div><span class="title">剩料率(%)</span><span class="num">{{feedingEfficiency.data.leftover_rate}}</span></div>
  884. <div><span class="title">TMR干物质(%)</span><span class="num">{{feedingEfficiency.data.tmr_dry_matter}}</span></div>
  885. <div><span class="title">配方干物质采食量(kg/头)</span><span class="num">{{feedingEfficiency.data.formulated_dry_matter_intake}}</span></div>
  886. <div><span class="title">实际干物质采食量(kg/头)</span><span class="num">{{feedingEfficiency.data.actual_dry_matter_intake}}</span></div>
  887. <div><span class="title">采食率(%)</span><span class="num">{{feedingEfficiency.data.food_intake_rate}}</span></div>
  888. <div><span class="title">配方成本(元/头)</span><span class="num">{{feedingEfficiency.data.cost_of_formulation}}</span></div>
  889. <div><span class="title">实际成本(元/头)</span><span class="num">{{feedingEfficiency.data.actual_cost}}</span></div>
  890. <div><span class="title">产奶量(kg/头)</span><span class="num">{{feedingEfficiency.data.milk_yield}}</span></div>
  891. <div><span class="title">饲料转化率(%)</span><span class="num">{{feedingEfficiency.data.feed_conversion_ratio}}</span></div>
  892. <div><span class="title">公斤奶饲料成本</span><span class="num">{{feedingEfficiency.data.feed_costs}}</span></div>
  893. </div>
  894. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  895. <el-button class="cancelClose1" @click="feedingEfficiency.dialogFormVisible = false; ">关闭</el-button>
  896. </div>
  897. </el-dialog>
  898. </div>
  899. </template>
  900. <script>
  901. import { postJson,getJson,delJson,exportFile,GetDataByName, GetDataByNames, PostDataByName, failproccess, checkButtons, ExecDataByConfig, formatNum } from '@/api/common'
  902. import Sortable from 'sortablejs'
  903. import { MessageBox } from 'element-ui'
  904. import Cookies from 'js-cookie'
  905. import { json2excel } from '@/utils/index.js'
  906. import axios from 'axios'
  907. import { getToken } from '@/utils/auth'
  908. import { parseTime } from '@/utils/index.js'
  909. import Pagination from '@/components/Pagination'
  910. import localDownloadUtil from "@/utils/localDownloadUtil.js";
  911. export default {
  912. name: 'RecipeTemplate',
  913. components: { Pagination },
  914. data() {
  915. return {
  916. isAdd1:'',isEdit1:'',isImport1:'',isExport1:'',isDelete1:'',isFormulaEvaluation:'',isUsageOverview:'',isCanceldistributingformula:'',isModify1:'',isEnable1:'',isModify2:'',
  917. predefineColors: [
  918. '#E57373', '#F06292', '#BA68C8', '#9575CD', '#7986CB', '#64B5F6', '#4FC3F7', '#4DD0E1', '#4DB6AC', '#81C784', '#AED581', '#DCE775', '#FFF176', '#FFD54F', '#FFB74D', '#FF8A65', '#A1887F', '#E0E0E0', '#90A4AE'
  919. ],
  920. livestockTypeList:JSON.parse(sessionStorage.downlist).cattle_parent_category, // 牲畜类别
  921. formulaTypeList: JSON.parse(sessionStorage.downlist).formula_type, // 配方类型
  922. enableList: JSON.parse(sessionStorage.downlist).is_show, // 是否启用
  923. sourceList: JSON.parse(sessionStorage.downlist).forage_source, //来源
  924. pastureList:JSON.parse(sessionStorage.pastureList), //牧场
  925. table: {
  926. page: 1,
  927. page_size: parseInt(Cookies.get('pageCount')),
  928. tableKey: 0,
  929. list: [],
  930. total: 0,
  931. listLoading: false,
  932. parammaps: {
  933. cattle_category_id: '',formula_type_id:'',data_source_id:'',is_show:'',name:'',remarks:''
  934. },
  935. temp: {}
  936. },
  937. isokDisable: false,
  938. dataForm:{
  939. name: "",
  940. file: null,
  941. },
  942. table2: {
  943. // getDryweightParm: {
  944. // name: 'getFTdryweight',
  945. // page: 1,
  946. // offset: 1,
  947. // pagecount: 10,
  948. // returntype: 'Map',
  949. // parammaps: {
  950. // pastureid: '',
  951. // ftid: ''
  952. // }
  953. // },
  954. // dryweight: '',
  955. parammaps: {
  956. pastureid: parseInt(Cookies.get('pastureId')),
  957. id:'',
  958. fname: '',
  959. feedgroup: '',
  960. fweight: '',
  961. autosecondname: '',
  962. islockcount: '',
  963. sort: ''
  964. },
  965. tableKey: 0,
  966. list: [],
  967. total: 0,
  968. listLoading: false,
  969. temp: {},
  970. },
  971. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  972. table3: {
  973. page: 1,
  974. page_size: parseInt(Cookies.get('pageCount')),
  975. tableKey: 0,
  976. list: [],
  977. total: 0,
  978. listLoading: true,
  979. parammaps: {
  980. name:'',inputDatetime:[],end_time:'',start_time:'',pasture_id:parseInt(Cookies.get('pastureId'))
  981. },
  982. temp: {}
  983. },
  984. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  985. cellStyle: { padding: 0 + 'px' },
  986. myheight1: document.documentElement.clientHeight - 265,
  987. distributeFormula:{
  988. dialogFormVisible: false,
  989. dialogStatus: '',
  990. table: {
  991. parammaps: {
  992. name:''
  993. },
  994. tableKey: 0,
  995. total: 0,
  996. listLoading: true,
  997. list: []
  998. },
  999. selectionList:[]
  1000. },
  1001. dialogFull: false,
  1002. textMap: {
  1003. distributeFormula: '选择牧场',
  1004. usageOverviewTxt:'使用概况',
  1005. feedingEfficiencyTxt:'饲喂效率'
  1006. },
  1007. // ==============================
  1008. isRoleEdit: [],
  1009. requestParams: [
  1010. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  1011. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  1012. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  1013. ],
  1014. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  1015. feedNameList: [], // 饲料名称
  1016. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  1017. arrowDown: true,
  1018. arrowUp: false,
  1019. ispastureuse: Cookies.get('ispastureuse'),
  1020. lockCount: {
  1021. getdataListParm: {
  1022. name: 'getSysoptEnable',
  1023. page: 1,
  1024. offset: 1,
  1025. pagecount: 30,
  1026. returntype: 'Map',
  1027. parammaps: {
  1028. pastureid: Cookies.get('pastureid'),
  1029. inforname: 'isLockCount'
  1030. }
  1031. },
  1032. isLockCount: false // 是否显示是否锁定牛头数比例
  1033. },
  1034. isDetail: false,
  1035. arrowDown2: true,
  1036. arrowUp2: false,
  1037. // table2: {
  1038. // getDryweightParm: {
  1039. // name: 'getFTdryweight',
  1040. // page: 1,
  1041. // offset: 1,
  1042. // pagecount: 10,
  1043. // returntype: 'Map',
  1044. // parammaps: {
  1045. // pastureid: '',
  1046. // ftid: ''
  1047. // }
  1048. // },
  1049. // dryweight: '',
  1050. // getdataListParm: {
  1051. // name: 'getFTdetailList',
  1052. // page: 1,
  1053. // offset: 1,
  1054. // pagecount: '',
  1055. // returntype: 'Map',
  1056. // parammaps: {
  1057. // pastureid: Cookies.get('pastureid'),
  1058. // fname: '',
  1059. // feedgroup: '',
  1060. // fweight: '',
  1061. // autosecondname: '',
  1062. // islockcount: '',
  1063. // sort: ''
  1064. // }
  1065. // },
  1066. // tableKey: 0,
  1067. // list: [],
  1068. // total: 0,
  1069. // listLoading: false,
  1070. // temp: {},
  1071. // updateList: {}
  1072. // },
  1073. isDetailDialog: false,
  1074. template: {
  1075. dialogFormVisible: false,
  1076. dialogStatus: '',
  1077. table: {
  1078. getdataListParm: {
  1079. name: 'getFTListDate',
  1080. page: 1,
  1081. offset: 1,
  1082. pagecount: '',
  1083. returntype: 'Map',
  1084. parammaps: {
  1085. pastureid: Cookies.get('pastureid'),
  1086. tname: '',
  1087. ccid: '',
  1088. ccname: '',
  1089. fttype: '',
  1090. remark: '',
  1091. enable: '',
  1092. date: '',
  1093. source: ''
  1094. }
  1095. },
  1096. tableKey: 0,
  1097. total: 0,
  1098. listLoading: true,
  1099. list: []
  1100. },
  1101. table2: {
  1102. getdataListParm: {
  1103. name: 'getFTdetailListDate',
  1104. page: 1,
  1105. offset: 1,
  1106. pagecount: 10,
  1107. returntype: 'Map',
  1108. parammaps: {
  1109. pastureid: Cookies.get('pastureid'),
  1110. fname: '',
  1111. fweight: '',
  1112. islockcount: '',
  1113. sort: '',
  1114. feedgroup: '',
  1115. autosecondname: ''
  1116. }
  1117. },
  1118. tableKey: 0,
  1119. total: 0,
  1120. listLoading: true,
  1121. list: []
  1122. },
  1123. // 历史日期
  1124. getdataDateParm: {
  1125. name: 'getFTMaxDate',
  1126. page: 1,
  1127. offset: 1,
  1128. pagecount: 10,
  1129. returntype: 'Map',
  1130. parammaps: {
  1131. pastureid: Cookies.get('pastureid')
  1132. }
  1133. }
  1134. },
  1135. isOrder: true,
  1136. detail: {
  1137. dialogFormVisible: false,
  1138. dialogStatus: '',
  1139. tableKey: 0,
  1140. total: 0,
  1141. listLoading: true,
  1142. list: [],
  1143. tableKey2: 0,
  1144. total2: 0,
  1145. listLoading2: false,
  1146. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  1147. getdataListParm: {
  1148. name: 'getFTDetailCompare',
  1149. page: 1,
  1150. offset: 1,
  1151. pagecount: 10,
  1152. returntype: 'Map',
  1153. parammaps: {}
  1154. },
  1155. list3: [],
  1156. disabled: false,
  1157. getdataListParm2: {
  1158. name: 'getFTCompare',
  1159. page: 1,
  1160. offset: 1,
  1161. pagecount: 10,
  1162. returntype: 'Map',
  1163. parammaps: {}
  1164. }
  1165. },
  1166. selectList: [],
  1167. selectList2: [],
  1168. // textMap: {
  1169. // RecipeRecord: '配方记录',
  1170. // SyntheticPremix: '合成预混料',
  1171. // historyRecord: '历史记录',
  1172. // detail: '饲料详情',
  1173. // rowRecipeRecordTxt: '配方修改记录'
  1174. // },
  1175. requestParam: {},
  1176. requestParam2: {},
  1177. requestParam3:{},
  1178. download: {
  1179. getdataListParm: {
  1180. name: 'getFTList',
  1181. page: 1,
  1182. offset: 1,
  1183. pagecount: 0,
  1184. returntype: 'Map',
  1185. parammaps: {
  1186. pastureid: Cookies.get('pastureid'),
  1187. tname: '',
  1188. ccid: '',
  1189. ccname: '',
  1190. fttypeid: '',
  1191. fttype: '',
  1192. remark: '',
  1193. enable: ''
  1194. }
  1195. },
  1196. list: []
  1197. },
  1198. historyRecord: {
  1199. dialogStatus: '',
  1200. dialogFormVisible: false
  1201. },
  1202. dropState: false,
  1203. myheight2: 0,
  1204. height: 0,
  1205. usageOverview: {
  1206. dialogStatus: '',
  1207. dialogFormVisible: false,
  1208. getdataListParm: {
  1209. name: 'getFitHistory1', 'name1': 'getFitHistory2', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  1210. parammaps: { inputDatetime: [new Date(), new Date()], pastureid: '', fitid: '' }
  1211. },
  1212. tableKey: 0, total: 0, listLoading: true, list: []
  1213. },
  1214. feedingEfficiency:{
  1215. dialogStatus: '',
  1216. dialogFormVisible: false,
  1217. data:{}
  1218. },
  1219. isEnlarge: true,
  1220. // enlargeHeight: document.documentElement.clientHeight - 85 - 165 + 50,
  1221. enlargeHeight: document.documentElement.clientHeight - 85 - 165 + 50,
  1222. getTcodeParm: {
  1223. name: 'getTcode', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  1224. parammaps: { pastureid: '', fttypeid: '' }
  1225. },
  1226. }
  1227. },
  1228. mounted() {
  1229. document.addEventListener('click', (e) => {
  1230. if (this.$refs.selectInput !== undefined) {
  1231. if (!this.$refs.selectInput.contains(e.target)) {
  1232. this.arrowDown = true
  1233. this.arrowUp = false
  1234. } else {
  1235. this.arrowDown = false
  1236. this.arrowUp = true
  1237. }
  1238. }
  1239. if (this.$refs.selectInput2 !== undefined) {
  1240. if (!this.$refs.selectInput2.contains(e.target)) {
  1241. this.arrowDown2 = true
  1242. this.arrowUp2 = false
  1243. } else {
  1244. this.arrowDown2 = false
  1245. this.arrowUp2 = true
  1246. }
  1247. }
  1248. })
  1249. },
  1250. created() {
  1251. this.getList()
  1252. this.getButton()
  1253. // this.getDownList()
  1254. // this.getIsLockCount()
  1255. },
  1256. methods: {
  1257. getButton(){
  1258. const add = 'recipe:recipeList:add'
  1259. this.isAdd1 = checkButtons(add)
  1260. const edit = 'recipe:recipeList:edit'
  1261. this.isEdit1 = checkButtons(edit)
  1262. const _import = 'recipe:recipeList:import'
  1263. this.isImport1 = checkButtons(_import)
  1264. const _export = 'recipe:recipeList:export'
  1265. this.isExport1 = checkButtons(_export)
  1266. const del = 'recipe:recipeList:delete'
  1267. this.isDelete1 = checkButtons(del)
  1268. const formulaEvaluation = 'recipe:recipeList:formulaEvaluation'
  1269. this.isFormulaEvaluation = checkButtons(formulaEvaluation)
  1270. const usageOverview = 'recipe:recipeList:usageOverview'
  1271. this.isUsageOverview = checkButtons(usageOverview)
  1272. const canceldistributingformula = 'recipe:recipeList:canceldistributingformula'
  1273. this.isCanceldistributingformula = checkButtons(canceldistributingformula)
  1274. const enable = 'recipe:recipeList:enable'
  1275. this.isEnable = checkButtons(enable)
  1276. const modify1 = 'recipe:recipeList:modify'
  1277. this.isModify1 = checkButtons(modify1)
  1278. const modify2 = 'recipe:recipeList:modify2'
  1279. this.isModify2 = checkButtons(modify2)
  1280. },
  1281. // -------------------模板-----------------------------
  1282. getList() {
  1283. this.table.listLoading = true
  1284. let page = this.table.page
  1285. let page_size = this.table.page_size
  1286. let url = '/api/v1/ops/feed_formula/list' + '?page=' + page + '&page_size=' + page_size
  1287. let data = {
  1288. "name":this.table.parammaps.name,
  1289. "remarks":this.table.parammaps.remarks
  1290. }
  1291. if(this.table.parammaps.cattle_category_id !== ''){
  1292. data.cattle_category_id = this.table.parammaps.cattle_category_id
  1293. }
  1294. if(this.table.parammaps.formula_type_id !== ''){
  1295. data.formula_type_id = this.table.parammaps.formula_type_id
  1296. }
  1297. if(this.table.parammaps.data_source_id !== ''){
  1298. data.data_source_id = this.table.parammaps.data_source_id
  1299. }
  1300. if(this.table.parammaps.is_show !== ''){
  1301. data.is_show = this.table.parammaps.is_show
  1302. }
  1303. postJson(url, data).then(response => {
  1304. if (response.code == 200) {
  1305. for (let i = 0; i < response.data.list.length; i++) {
  1306. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1307. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1308. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1309. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1310. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1311. }
  1312. this.table.list = response.data.list
  1313. this.table.total = response.data.total
  1314. this.table.pageNum = response.data.page
  1315. this.table.pageSize = response.data.page_size
  1316. } else {
  1317. this.table.list = []
  1318. }
  1319. setTimeout(() => {
  1320. this.table.listLoading = false
  1321. }, 1000)
  1322. })
  1323. },
  1324. handleSearch1() {
  1325. console.log('点击了查询')
  1326. this.table.page = 1
  1327. this.getList()
  1328. this.arrowDown = true
  1329. this.arrowUp = false
  1330. },
  1331. handleRefresh1() {
  1332. console.log('点击了重置')
  1333. this.table.page = 1
  1334. this.table.parammaps.cattle_category_id = ''
  1335. this.table.parammaps.formula_type_id = ''
  1336. this.table.parammaps.data_source_id = ''
  1337. this.table.parammaps.is_show = ''
  1338. this.table.parammaps.name = ''
  1339. this.table.parammaps.remarks = ''
  1340. this.getList()
  1341. },
  1342. // 模板新增
  1343. handleCreate1() {
  1344. // 编辑true/不可编辑false
  1345. // 新增操true,编辑false,编辑保存false
  1346. for (let i = 0; i < this.table.list.length; i++) {
  1347. if (this.table.list[i].Edit === true) {
  1348. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1349. return false
  1350. }
  1351. }
  1352. this.table.list.unshift({
  1353. 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false,
  1354. 'name': '', 'encode_number': '', 'colour': '#ccc',
  1355. 'cattle_category_id': '', 'cattle_category_name': '',
  1356. 'formula_type_id': '', 'formula_type_name': '',
  1357. 'data_source_id':2,'data_source_name': '用户自定义',
  1358. 'remarks': '','is_show': 1 ,'is_modify':1
  1359. })
  1360. this.table.temp = this.table.list[0]
  1361. this.get_encodenumber()
  1362. },
  1363. get_encodenumber(){
  1364. let url = 'api/v1/ops/feed_formula/encode_number'
  1365. let data = ''
  1366. getJson(url, data).then(response => {
  1367. this.table.temp.encode_number = response.data.encode_number
  1368. })
  1369. },
  1370. // 牲畜类别
  1371. changeLivestockType1(item) {
  1372. this.table.temp.cattle_category_name = this.livestockTypeList.find(obj => obj.value == item).label
  1373. },
  1374. // 配方类型
  1375. changeFormulaType1(item) {
  1376. this.table.temp.formula_type_name = this.formulaTypeList.find(obj => obj.value == item).label
  1377. },
  1378. handleEnableChange1(index,row,type){
  1379. let edit_type = ''
  1380. let is_show = ''
  1381. if(type == 'show'){
  1382. edit_type = 1
  1383. is_show = row.is_show
  1384. }else{
  1385. edit_type = 2
  1386. is_show = row.is_modify
  1387. }
  1388. let url = '/api/v1/ops/feed_formula/is_modify_show'
  1389. let data = {
  1390. "feed_formula_id":row.id,
  1391. "is_show":is_show,
  1392. 'edit_type':edit_type
  1393. }
  1394. postJson(url,data).then(response => {
  1395. if(response.code == 200){
  1396. this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
  1397. this.getList()
  1398. }
  1399. })
  1400. },
  1401. createData1(row) {
  1402. this.table.temp.name = row.name
  1403. this.table.temp.encode_number = row.encode_number
  1404. this.table.temp.colour = row.colour
  1405. this.table.temp.cattle_category_id = row.cattle_category_id
  1406. this.table.temp.cattle_category_name = row.cattle_category_name
  1407. this.table.temp.formula_type_id = row.formula_type_id
  1408. this.table.temp.formula_type_name = row.formula_type_name
  1409. this.table.temp.is_show = row.is_show
  1410. this.table.temp.is_modify = row.is_modify
  1411. this.table.temp.data_source_id = row.data_source_id
  1412. this.table.temp.data_source_name = row.data_source_name
  1413. this.table.temp.remarks = row.remarks
  1414. if (this.table.temp.name == '' && this.table.temp.cattle_category_id == '' && this.table.temp.formula_type_id == '') {
  1415. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1416. return false
  1417. } else if (this.table.temp.cattle_category_id == '' && this.table.temp.formula_type_id == '') {
  1418. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1419. return false
  1420. } else if (this.table.temp.name == '') {
  1421. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1422. return false
  1423. } else if (this.table.temp.cattle_category_id == '') {
  1424. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1425. return false
  1426. } else if (this.table.temp.formula_type_id == '') {
  1427. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1428. return false
  1429. }
  1430. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1431. if (pattern.test(this.table.temp.encode_number)) {
  1432. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1433. return false
  1434. }
  1435. console.log(this.table.temp)
  1436. this.isokDisable = true
  1437. setTimeout(() => {
  1438. this.isokDisable = false
  1439. }, 1000)
  1440. let url = '/api/v1/ops/feed_formula/add'
  1441. let data = {
  1442. "name": this.table.temp.name,
  1443. "encode_number": this.table.temp.encode_number,
  1444. "colour": this.table.temp.colour,
  1445. "cattle_category_id": this.table.temp.cattle_category_id,
  1446. "cattle_category_name": this.table.temp.cattle_category_name,
  1447. "formula_type_id": this.table.temp.formula_type_id,
  1448. "formula_type_name": this.table.temp.formula_type_name,
  1449. "data_source_id": this.table.temp.data_source_id,
  1450. "data_source_name": this.table.temp.data_source_name,
  1451. "remarks": this.table.temp.remarks,
  1452. "is_show": this.table.temp.is_show,
  1453. "is_modify": this.table.temp.is_modify,
  1454. }
  1455. if(this.table.temp.remarks !== ''){
  1456. data.remarks = this.table.temp.remarks
  1457. }
  1458. postJson(url, data).then(response => {
  1459. if(response.code == 200){
  1460. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1461. this.getList()
  1462. }
  1463. })
  1464. },
  1465. createCancel1(row) {
  1466. for (let i = 0; i < this.table.list.length; i++) {
  1467. if (row.myId === this.table.list[i].myId) {
  1468. var listIndex = this.table.list.indexOf(this.table.list[i])
  1469. }
  1470. if (listIndex > -1) {
  1471. this.table.list.splice(listIndex, 1)
  1472. return
  1473. }
  1474. }
  1475. },
  1476. // 模板编辑
  1477. handleUpdate1(row) {
  1478. for (let i = 0; i < this.table.list.length; i++) {
  1479. if (this.table.list[i].Edit == true) {
  1480. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1481. return false
  1482. }
  1483. }
  1484. this.table.temp = Object.assign({}, row)
  1485. // 编辑true,不可编辑false
  1486. row.Edit = true
  1487. row.NoEdit = false
  1488. // 新增false,编辑false,编辑保存true
  1489. row.isCreate = false
  1490. row.isUpdate = false
  1491. row.isUpdateSave = true
  1492. },
  1493. updateData1(row) {
  1494. this.table.temp.name = row.name
  1495. this.table.temp.encode_number = row.encode_number
  1496. this.table.temp.colour = row.colour
  1497. this.table.temp.cattle_category_id = row.cattle_category_id
  1498. this.table.temp.cattle_category_name = row.cattle_category_name
  1499. this.table.temp.formula_type_id = row.formula_type_id
  1500. this.table.temp.formula_type_name = row.formula_type_name
  1501. this.table.temp.is_show = row.is_show
  1502. this.table.temp.is_modify = row.is_modify
  1503. this.table.temp.data_source_id = row.data_source_id
  1504. this.table.temp.data_source_name = row.data_source_name
  1505. this.table.temp.remarks = row.remarks
  1506. if (this.table.temp.name == '' && this.table.temp.cattle_category_id == '' && this.table.temp.formula_type_id == '') {
  1507. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1508. return false
  1509. } else if (this.table.temp.cattle_category_id == '' && this.table.temp.formula_type_id == '') {
  1510. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1511. return false
  1512. } else if (this.table.temp.name == '') {
  1513. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1514. return false
  1515. } else if (this.table.temp.cattle_category_id == '') {
  1516. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1517. return false
  1518. } else if (this.table.temp.formula_type_id == '') {
  1519. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1520. return false
  1521. }
  1522. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1523. if (pattern.test(this.table.temp.encode_number)) {
  1524. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1525. return false
  1526. }
  1527. this.isokDisable = true
  1528. setTimeout(() => {
  1529. this.isokDisable = false
  1530. }, 1000)
  1531. let url = '/api/v1/ops/feed_formula/edit'
  1532. let data = {
  1533. "name": this.table.temp.name,
  1534. "encode_number": this.table.temp.encode_number,
  1535. "colour": this.table.temp.colour,
  1536. "cattle_category_id": this.table.temp.cattle_category_id,
  1537. "cattle_category_name": this.table.temp.cattle_category_name,
  1538. "formula_type_id": this.table.temp.formula_type_id,
  1539. "formula_type_name": this.table.temp.formula_type_name,
  1540. "data_source_id": this.table.temp.data_source_id,
  1541. "data_source_name": this.table.temp.data_source_name,
  1542. "remarks": this.table.temp.remarks,
  1543. "is_show": this.table.temp.is_show,
  1544. "is_modify": this.table.temp.is_modify,
  1545. 'id':this.table.temp.id
  1546. }
  1547. if(this.table.temp.remarks !== ''){
  1548. data.remarks = this.table.temp.remarks
  1549. }
  1550. postJson(url, data).then(response => {
  1551. if(response.code == 200){
  1552. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1553. this.getList()
  1554. }
  1555. })
  1556. },
  1557. updateCancel1(row) {
  1558. console.log('点击了编辑取消')
  1559. // 编辑false,不可编辑true
  1560. row.Edit = false
  1561. row.NoEdit = true
  1562. // 新增false,编辑 true,编辑保存false
  1563. row.isCreate = false
  1564. row.isUpdate = true
  1565. row.isUpdateSave = false
  1566. this.getList()
  1567. },
  1568. handleRowDelete1(row){
  1569. MessageBox.confirm('确定删除吗?', {
  1570. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1571. }).then(() => {
  1572. let url = 'api/v1/ops/feed_formula/delete/'
  1573. let data = row.id
  1574. delJson(url, data).then(response => {
  1575. if (response.code == 200) {
  1576. this.$notify({
  1577. title: '',
  1578. message: '删除成功',
  1579. type: 'success',
  1580. duration: 2000
  1581. })
  1582. this.getList()
  1583. }
  1584. })
  1585. })
  1586. },
  1587. handleExport(item) {
  1588. if (item == 1) {
  1589. console.log('导出模板')
  1590. let url = 'api/v1/ops/feed_formula/excel_template'
  1591. let data = {name:''}
  1592. exportFile(url, data).then(response => {
  1593. let xlxsname = '配方列表模板' + parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}') + '.xlsx'
  1594. localDownloadUtil.blobDownloads(response,xlxsname)
  1595. })
  1596. } else {
  1597. console.log('导出数据')
  1598. let url = 'api/v1/ops/feed_formula/excel_export'
  1599. let data = {name:''}
  1600. exportFile(url, data).then(response => {
  1601. let xlxsname = '配方列表' + parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}') + '.xlsx'
  1602. localDownloadUtil.blobDownloads(response,xlxsname)
  1603. })
  1604. }
  1605. },
  1606. handleImport(){
  1607. let url = 'api/v1/ops/forage/excel_import'
  1608. let data = {name:''}
  1609. importFile(url, data).then(response => {
  1610. })
  1611. },
  1612. //验证文件类型
  1613. beforeAvatarUpload(file) {
  1614. console.log(file);
  1615. const isXls = file.type === "application/vnd.ms-excel" ? true : file.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ? true : false;
  1616. if (!isXls) {
  1617. alert("上传的文件只能是xls以及xlsx格式!");
  1618. }
  1619. return isXls;
  1620. },
  1621. // 判断文件个数
  1622. handleChange(file, fileList) {
  1623. if (fileList.length >= 2) {
  1624. return;
  1625. }
  1626. if (fileList.length === 1) {
  1627. this.hasFile = true;
  1628. }
  1629. this.dataForm.file = file;
  1630. },
  1631. // 导入
  1632. httpRequest(param) {
  1633. let formData = new FormData();
  1634. formData.append('file', this.dataForm.file.raw);
  1635. let url = 'api/v1/ops/forage/excel_import';
  1636. let data = formData
  1637. console.log(param.file);
  1638. axios({
  1639. method: 'POST',
  1640. url: process.env.VUE_APP_BASE_API + url,
  1641. data: data,
  1642. headers: {
  1643. 'Authorization': 'Bearer ' + getToken(),
  1644. 'Content-Type': 'multipart/form-data'
  1645. }
  1646. }).then(res => {
  1647. if(res.data.code == 200){
  1648. this.$notify({ title: '成功', message:'操作成功', type: 'success', duration: 2000 })
  1649. this.getList()
  1650. }
  1651. }).catch((e) => {
  1652. console.log(e);
  1653. });
  1654. },
  1655. // 下发配方
  1656. handleDistributeFormula(){
  1657. if(this.selectList.length>0){
  1658. this.distributeFormula.dialogStatus = 'distributeFormula'
  1659. this.distributeFormula.dialogFormVisible = true
  1660. this.dialogFull = false
  1661. this.getPastureList()
  1662. }else{
  1663. this.$message({ type: 'error', message: '请先选择配方', duration: 2000 })
  1664. }
  1665. },
  1666. getPastureList(){
  1667. this.distributeFormula.table.listLoading = true
  1668. let page = 1
  1669. let page_size = 0
  1670. let url = 'api/v1/ops/pasture/list' + '?page=' + page + '&page_size=' + page_size
  1671. let data = {
  1672. "name":this.distributeFormula.table.parammaps.name
  1673. }
  1674. postJson(url, data).then(response => {
  1675. if (response.code == 200) {
  1676. this.distributeFormula.table.list = response.data.list
  1677. } else {
  1678. this.distributeFormula.table.list = []
  1679. }
  1680. setTimeout(() => {
  1681. this.distributeFormula.table.listLoading = false
  1682. }, 1000)
  1683. })
  1684. },
  1685. handleDistributeFormulaSearch(){
  1686. this.getPastureList()
  1687. },
  1688. handleDistributeFormulaRefresh(){
  1689. this.distributeFormula.table.parammaps.name = ''
  1690. },
  1691. handleSelectionDistributeFormula(item){
  1692. this.distributeFormula.selectionList = item
  1693. console.log(this.distributeFormula.selectionList)
  1694. },
  1695. distributeFormulaData(){
  1696. let feed_formula_ids = []
  1697. let pasture_ids = []
  1698. this.distributeFormula.selectionList.forEach((item)=>{
  1699. pasture_ids.push(item.id)
  1700. })
  1701. this.selectList.forEach((item)=>{
  1702. feed_formula_ids.push(item.id)
  1703. })
  1704. this.isokDisable = true
  1705. setTimeout(() => {
  1706. this.isokDisable = false
  1707. }, 1000)
  1708. let url = '/api/v1/ops/feed_formula/distribute'
  1709. let data = {
  1710. feed_formula_ids:feed_formula_ids,
  1711. pasture_ids:pasture_ids
  1712. }
  1713. postJson(url, data).then(response => {
  1714. if(response.code == 200){
  1715. this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
  1716. this.distributeFormula.dialogFormVisible = false
  1717. this.getList()
  1718. }
  1719. })
  1720. },
  1721. // 模板行点击
  1722. table1RowClick(row, column, event) {
  1723. for (let i = 0; i < this.table.list.length; i++) {
  1724. if (this.table.list[i].Edit == true) {
  1725. return false
  1726. }
  1727. }
  1728. if (this.isOrder == false) {
  1729. this.$message({ type: 'error', message: '请保存或取消当前更改顺序操作', duration: 2000 })
  1730. } else {
  1731. if (column.label !== '操作' && column.label !== '是否启用' && column.label !== '是否可修改' && column.label !== '版本号') {
  1732. this.isDetail = true // 点击行显示详情
  1733. this.myheight1 = document.documentElement.clientHeight - 85 - 265 - 185
  1734. console.log(row,'====')
  1735. this.table2.parammaps.id = row.id
  1736. this.table2.parammaps.formula_type_id = row.formula_type_id
  1737. this.table3.parammaps.id = row.id
  1738. this.getList2()
  1739. this.getList3()
  1740. this.getFeedNameList()
  1741. }
  1742. }
  1743. },
  1744. getFeedNameList(){
  1745. let page = 0
  1746. let page_size = 0
  1747. let url = 'api/v1/ops/forage/list' + '?page=' + page + '&page_size=' + page_size
  1748. let data = {}
  1749. postJson(url, data).then(response => {
  1750. if (response.code == 200) {
  1751. this.feedNameList = response.data.list
  1752. } else {
  1753. this.feedNameList = []
  1754. }
  1755. })
  1756. },
  1757. // 详情
  1758. getList2(item) {
  1759. this.table2.listLoading = true
  1760. let url = ''
  1761. let data = {}
  1762. if(item == 'search'){
  1763. url = 'api/v1/ops/feed_formula/feed/search'
  1764. data.feed_formula_id = this.table2.parammaps.id
  1765. data.forage_name = this.table2.parammaps.forage_name
  1766. data.forage_group_name = this.table2.parammaps.forage_group_name
  1767. if(this.table2.parammaps.weight){
  1768. data.weight = this.table2.parammaps.weight
  1769. }
  1770. if(this.table2.parammaps.is_lock_cow_count_ratio){
  1771. data.is_lock_cow_count_ratio = this.table2.parammaps.is_lock_cow_count_ratio
  1772. }
  1773. if(this.table2.parammaps.sort){
  1774. data.sort = this.table2.parammaps.sort
  1775. }
  1776. }else{
  1777. url = 'api/v1/ops/feed_formula/feed_detail/list'
  1778. data.feed_formula_id = this.table2.parammaps.id
  1779. }
  1780. postJson(url, data).then(response => {
  1781. if (response.data) {
  1782. for (let i = 0; i < response.data.length; i++) {
  1783. this.$set(response.data[i], 'Edit', false) // 编辑
  1784. this.$set(response.data[i], 'NoEdit', true) // 不可编辑/输入
  1785. this.$set(response.data[i], 'groupEdit', false) // 饲料组编辑
  1786. this.$set(response.data[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1787. this.$set(response.data[i], 'groupNoEdit', true) // 饲料组不可编辑
  1788. this.$set(response.data[i], 'isCreate', false) // 新增操作
  1789. this.$set(response.data[i], 'isUpdate', true) // 编辑操作
  1790. this.$set(response.data[i], 'isUpdateSave', false) // 编辑保存
  1791. }
  1792. // this.table2.getDryweightParm.parammaps = this.table2.getdataListParm.parammaps
  1793. // this.getDryWeight()
  1794. this.table2.list = response.data
  1795. console.log('table2数据', this.table2.list)
  1796. this.table2.total = response.data.total
  1797. } else {
  1798. this.table2.list = []
  1799. }
  1800. setTimeout(() => {
  1801. this.table2.listLoading = false
  1802. }, 100)
  1803. })
  1804. },
  1805. form_search2() {
  1806. console.log('点击了查询')
  1807. this.arrowDown2 = true
  1808. this.arrowUp2 = false
  1809. this.table2.offset = 1
  1810. this.table2.parammaps.all = ''
  1811. var obj = {}
  1812. obj.fname = this.table2.parammaps.fname
  1813. obj.feedgroup = this.table2.parammaps.feedgroup
  1814. obj.fweight = this.table2.parammaps.fweight
  1815. obj.autosecondname = this.table2.parammaps.autosecondname
  1816. if (this.table2.parammaps.islockcount !== '') {
  1817. if (this.table2.parammaps.islockcount == 0) {
  1818. this.table2.parammaps.islockcount = '否'
  1819. } else {
  1820. this.table2.parammaps.islockcount = '是'
  1821. }
  1822. }
  1823. obj.islockcount = this.table2.parammaps.islockcount
  1824. obj.sort = this.table2.parammaps.sort
  1825. Object.getOwnPropertyNames(obj).forEach((key) => {
  1826. console.log(key, obj[key])
  1827. if (obj[key] !== '') {
  1828. this.table2.parammaps.all += obj[key] + '/'
  1829. }
  1830. })
  1831. if (this.table2.parammaps.all.charAt(this.table2.parammaps.all.length - 1) == '/') {
  1832. this.table2.parammaps.all = this.table2.parammaps.all.slice(0, this.table2.parammaps.all.length - 1)
  1833. }
  1834. this.getList2('search')
  1835. },
  1836. handleRefresh2() {
  1837. console.log('点击了重置')
  1838. this.table2.parammaps.forage_name = ''
  1839. this.table2.parammaps.forage_group_name = ''
  1840. this.table2.parammaps.weight = ''
  1841. this.table2.parammaps.allow_error = ''
  1842. this.table2.parammaps.islockcount = '0'
  1843. this.table2.parammaps.sort = ''
  1844. this.table2.parammaps.all = ''
  1845. this.table2.offset = 1
  1846. this.getList2('search')
  1847. },
  1848. changeFname(item, row) {
  1849. console.log(item, row)
  1850. this.table2.temp.forage_name = this.feedNameList.find(obj => obj.id == item).name
  1851. row.forage_name = this.feedNameList.find(obj => obj.id == item).name
  1852. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1853. this.table2.temp.preftid = '0'
  1854. } else {
  1855. this.table2.temp.preftid = item
  1856. }
  1857. if (row.sort == '') {
  1858. row.forage_group_name = this.table2.temp.forage_name
  1859. } else {
  1860. if (row.isCreate == true) { // 新增状态下
  1861. for (let i = 1; i < this.table2.list.length; i++) {
  1862. if (this.table2.list[i].sort == row.sort) {
  1863. console.log(this.table2.list[i])
  1864. row.forage_group_name = this.table2.list[i].forage_group_name
  1865. break
  1866. } else {
  1867. row.forage_group_name = this.table2.temp.forage_name
  1868. }
  1869. }
  1870. } else if (row.isUpdateSave == true) { // 编辑状态下
  1871. var Arr = []
  1872. for (let i = 0; i < this.table2.list.length; i++) {
  1873. Arr.push(this.table2.list[i].sort)
  1874. }
  1875. var Count = 0
  1876. for (let i = 0; i < Arr.length; i++) {
  1877. if (Arr[i] == row.sort) {
  1878. Count++
  1879. }
  1880. }
  1881. for (let i = 0; i < this.table2.list.length; i++) {
  1882. if (Count > 1) {
  1883. row.forage_group_name = this.table2.list[i].forage_group_name
  1884. console.log(this.table2.list[i].forage_group_name)
  1885. break
  1886. } else if (Count == 1) {
  1887. row.forage_group_name = this.table2.temp.forage_name
  1888. console.log(222, this.table2.temp.forage_name)
  1889. }
  1890. }
  1891. }
  1892. }
  1893. },
  1894. // 详情新增
  1895. handleCreate2() {
  1896. console.log('点击了详情新增', this.table2.list)
  1897. // 编辑true/不可编辑false
  1898. // 新增操true,编辑false,编辑保存false
  1899. for (let i = 0; i < this.table2.list.length; i++) {
  1900. if (this.table2.list[i].Edit === true) {
  1901. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1902. return false
  1903. }
  1904. }
  1905. if (this.table2.list.length == 0) {
  1906. var mysort = 0
  1907. } else {
  1908. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1909. }
  1910. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'is_modify': 1, 'forage_group_name': '', 'forage_id': '', 'forage_name': '', 'weight': '', 'stir_delay': '0','allow_error':0,'islockcount': '0', 'sort': mysort })
  1911. console.log(this.table2.list)
  1912. },
  1913. createData2(row) {
  1914. console.log('点击了详情新增保存1', row)
  1915. this.table2.temp.pastureid = Cookies.get('pastureid')
  1916. this.table2.temp.forage_id = row.forage_id
  1917. this.table2.temp.forage_name = this.table2.temp.forage_name
  1918. this.table2.temp.weight = row.weight
  1919. this.table2.temp.islockcount = row.islockcount
  1920. this.table2.temp.sort = row.sort
  1921. this.table2.temp.forage_group_name = row.forage_group_name
  1922. this.table2.temp.preftid = this.table2.temp.preftid
  1923. this.table2.temp.stir_delay = row.stir_delay
  1924. this.table2.temp.allow_error = row.allow_error
  1925. this.table2.temp.is_modify = row.is_modify
  1926. if (this.table2.temp.forage_id === '' && this.table2.temp.weight === '' && this.table2.temp.stir_delay === '' && this.table2.temp.allow_error === '') {
  1927. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时/允许延时偏差不能为空', duration: 2000 })
  1928. return false
  1929. } else if (this.table2.temp.weight === '' && this.table2.temp.stir_delay === '' && this.table2.temp.allow_error === '') {
  1930. this.$message({ type: 'error', message: '重量/搅拌延时/允许延时偏差不能为空', duration: 2000 })
  1931. return false
  1932. } else if (this.table2.temp.stir_delay === '' && this.table2.temp.allow_error === '') {
  1933. this.$message({ type: 'error', message: '搅拌延时/允许延时偏差不能为空', duration: 2000 })
  1934. return false
  1935. }else if (this.table2.temp.forage_id === '') {
  1936. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1937. return false
  1938. } else if (this.table2.temp.fweight === '') {
  1939. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1940. return false
  1941. } else if (this.table2.temp.stir_delay === '') {
  1942. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1943. return false
  1944. } else if (this.table2.temp.allow_error === '') {
  1945. this.$message({ type: 'error', message: '允许延时偏差不能为空', duration: 2000 })
  1946. return false
  1947. }
  1948. if(parseFloat(this.table2.temp.allow_error) > parseFloat(this.table2.temp.stir_delay)){
  1949. this.$message({ type: 'error', message: '允许延时偏差不可超出搅拌延时', duration: 2000 })
  1950. return false
  1951. }
  1952. if (this.table2.temp.sort !== '') {
  1953. this.table2.temp.sort = this.table2.temp.sort
  1954. } else {
  1955. console.log(this.table2.list.length)
  1956. if (this.table2.list.length == 1) {
  1957. this.table2.temp.sort = 1
  1958. } else {
  1959. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1960. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1961. }
  1962. }
  1963. if (this.table2.parammaps.formula_type_id == 2) {
  1964. if (parseInt(this.table2.temp.preftid) > 0) {
  1965. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1966. return false
  1967. }
  1968. }
  1969. // 校验顺序是否>=0
  1970. var ruleSort = /^\d+$/
  1971. if (!ruleSort.test(this.table2.temp.sort)) {
  1972. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1973. return false
  1974. }
  1975. // 检验重量>0
  1976. this.table2.temp.weight = formatNum(this.table2.temp.weight, 4) // 根据默认参数设置小数位数
  1977. row.weight = formatNum(row.weight, 4)
  1978. if (this.table2.temp.weight == 0) {
  1979. this.$message({ type: 'error', message: '重量请输入正数,最多保留四位小数', duration: 2000 })
  1980. return false
  1981. }
  1982. this.isokDisable = true
  1983. setTimeout(() => {
  1984. this.isokDisable = false
  1985. }, 1000)
  1986. let dateTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
  1987. const url = 'api/v1/ops/feed_formula/feed/add'
  1988. const data = {
  1989. 'feed_formula_id':this.table2.parammaps.id,
  1990. 'list':[
  1991. {
  1992. "feed_formula_id": this.table2.parammaps.id,
  1993. "forage_id": this.table2.temp.forage_id,
  1994. "forage_name": this.table2.temp.forage_name,
  1995. "forage_group_name": this.table2.temp.forage_group_name,
  1996. "sort": parseFloat(this.table2.temp.sort),
  1997. "is_modify": this.table2.temp.is_modify
  1998. }
  1999. ]
  2000. }
  2001. if(this.table2.temp.weight){
  2002. this.$set(data.list[0],'weight',parseFloat(this.table2.temp.weight))
  2003. }
  2004. if(this.table2.temp.stir_delay){
  2005. this.$set(data.list[0],'stir_delay',parseFloat(this.table2.temp.stir_delay))
  2006. }
  2007. if(this.table2.temp.allow_error){
  2008. this.$set(data.list[0],'allow_error',parseFloat(this.table2.temp.allow_error))
  2009. }
  2010. postJson(url, data).then(response => {
  2011. if (response.msg !== 'fail') {
  2012. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2013. this.getList2()
  2014. } else {
  2015. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2016. }
  2017. })
  2018. },
  2019. createCancel2(row) {
  2020. console.log('点击了详情新增取消')
  2021. for (let i = 0; i < this.table2.list.length; i++) {
  2022. if (row.myId === this.table2.list[i].myId) {
  2023. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  2024. }
  2025. if (listIndex > -1) {
  2026. this.table2.list.splice(listIndex, 1)
  2027. return
  2028. }
  2029. }
  2030. this.getDialogList()
  2031. },
  2032. // 行拖拽
  2033. rowDrop() {
  2034. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  2035. const that = this
  2036. var sortable = Sortable.create(tbody, {
  2037. disabled: that.dropState,
  2038. onChoose({ newIndex, oldIndex }) {
  2039. console.log(that.isOrder, 'that.isOrder == false')
  2040. console.log(that.dropState, 'that.dropState')
  2041. if (that.dropState == true || that.isOrder == true) {
  2042. sortable.destroy()
  2043. }
  2044. },
  2045. onEnd({ newIndex, oldIndex }) {
  2046. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  2047. that.table2.list.splice(newIndex, 0, currRow)
  2048. console.log('索引', newIndex)
  2049. console.log('拖动数据', currRow)
  2050. console.log('上', that.table2.list[newIndex - 1])
  2051. console.log('下', that.table2.list[newIndex + 1])
  2052. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  2053. for (let i = 0; i < that.table2.list.length; i++) {
  2054. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  2055. }
  2056. currRow.sort = 0
  2057. currRow.feedgroup = currRow.fname
  2058. console.log('拖动至最上方无值')
  2059. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  2060. currRow.sort = that.table2.list[newIndex - 1].sort
  2061. console.log('拖动值顺序等于上值顺序')
  2062. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  2063. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  2064. currRow.feedgroup = currRow.fname
  2065. console.log('拖动至最下方无值')
  2066. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  2067. currRow.sort == that.table2.list[newIndex + 1].sort
  2068. console.log('拖动值顺序等于下值顺序')
  2069. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  2070. currRow.sort = that.table2.list[newIndex - 1].sort
  2071. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  2072. console.log('拖动至上下顺序一致')
  2073. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  2074. console.log('上下')
  2075. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  2076. console.log(newIndex)
  2077. for (let i = newIndex; i < that.table2.list.length; i++) {
  2078. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  2079. }
  2080. }
  2081. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  2082. currRow.feedgroup = currRow.fname
  2083. console.log(that.table2.list[newIndex + 1].sort)
  2084. }
  2085. }
  2086. })
  2087. console.log(sortable.option('disabled'))
  2088. },
  2089. handleChangeOrder() {
  2090. this.isOrder = false
  2091. this.rowDrop()
  2092. },
  2093. saveChangeOrder() {
  2094. // 保存顺序
  2095. console.log(this.table2.list)
  2096. let list = []
  2097. for(let i=0;i<this.table2.list.length;i++){
  2098. let obj = {
  2099. feed_formula_id:this.table2.list[i].feed_formula_id,
  2100. id:this.table2.list[i].id,
  2101. forage_id:this.table2.list[i].forage_id,
  2102. forage_name:this.table2.list[i].forage_name,
  2103. forage_group_name:this.table2.list[i].forage_group_name,
  2104. weight:this.table2.list[i].weight,
  2105. stir_delay:this.table2.list[i].stir_delay,
  2106. allow_error:this.table2.list[i].allow_error,
  2107. sort:this.table2.list[i].sort,
  2108. is_modify: this.table2.list[i].is_modify
  2109. }
  2110. list.push(obj)
  2111. }
  2112. let url = 'api/v1/ops/feed_formula/feed/sort'
  2113. const data = {
  2114. 'feed_formula_id':this.table2.parammaps.id,
  2115. 'list':list
  2116. }
  2117. postJson(url, data).then(response => {
  2118. if (response.msg === 'fail') {
  2119. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  2120. } else {
  2121. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  2122. this.getList2()
  2123. this.isOrder = true
  2124. }
  2125. })
  2126. },
  2127. cancelChangeOrder() {
  2128. // 取消顺序
  2129. this.getList2()
  2130. this.isOrder = true
  2131. },
  2132. // 详情编辑
  2133. handleUpdate2(row) {
  2134. console.log('详情编辑', row)
  2135. this.dropState = true
  2136. row.isGroupDisabled = false
  2137. row.islockcount = String(row.islockcount)
  2138. this.table2.temp.forage_name = row.forage_name
  2139. this.table2.temp.preftid = row.preftid
  2140. const rowArr = []
  2141. for (let i = 0; i < this.table2.list.length; i++) {
  2142. if (this.table2.list[i].Edit == true) {
  2143. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  2144. return false
  2145. }
  2146. rowArr.push(this.table2.list[i].sort)
  2147. }
  2148. var count = 0
  2149. for (let i = 0; i < rowArr.length; i++) {
  2150. if (rowArr[i] == row.sort) {
  2151. count++
  2152. }
  2153. }
  2154. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  2155. if (count == 1) {
  2156. // 饲料组编辑false,不可编辑true
  2157. row.groupEdit = false
  2158. row.groupNoEdit = true
  2159. // 编辑true,不可编辑false
  2160. row.Edit = true
  2161. row.NoEdit = false
  2162. // 新增false,编辑false,编辑保存true
  2163. row.isCreate = false
  2164. row.isUpdate = false
  2165. row.isUpdateSave = true
  2166. } else if (count > 1) {
  2167. // 饲料组编辑true,不可编辑false
  2168. row.groupEdit = true
  2169. row.groupNoEdit = false
  2170. // 编辑true,不可编辑false
  2171. row.Edit = true
  2172. row.NoEdit = false
  2173. // 新增false,编辑false,编辑保存true
  2174. row.isCreate = false
  2175. row.isUpdate = false
  2176. row.isUpdateSave = true
  2177. return false
  2178. }
  2179. if(row.stir_delay == undefined){
  2180. row.stir_delay = ''
  2181. this.$set(row,'stir_delay','')
  2182. }
  2183. if(row.allow_error == undefined){
  2184. row.allow_error = ''
  2185. this.$set(row,'allow_error','')
  2186. }
  2187. console.log('详情编辑', row)
  2188. this.table2.updateList = Object.assign({}, row)
  2189. },
  2190. updateData2(row) {
  2191. console.log('点击了详情编辑保存', row)
  2192. this.isokDisable = true
  2193. setTimeout(() => {
  2194. this.isokDisable = false
  2195. }, 1000)
  2196. this.table2.temp.pastureid = Cookies.get('pastureid')
  2197. this.table2.temp.forage_id = row.forage_id
  2198. this.table2.temp.forage_name = this.table2.temp.forage_name
  2199. this.table2.temp.weight = row.weight
  2200. this.table2.temp.islockcount = row.islockcount
  2201. this.table2.temp.sort = row.sort
  2202. this.table2.temp.id = row.id
  2203. this.table2.temp.forage_group_name = row.forage_group_name
  2204. this.table2.temp.preftid = this.table2.temp.preftid
  2205. this.table2.temp.stir_delay = row.stir_delay
  2206. this.table2.temp.allow_error = row.allow_error
  2207. if (this.table2.temp.forage_id === '' && this.table2.temp.weight === '' && this.table2.temp.stir_delay === '' && this.table2.temp.allow_error === '') {
  2208. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时/允许延时偏差不能为空', duration: 2000 })
  2209. return false
  2210. } else if (this.table2.temp.weight === '' && this.table2.temp.stir_delay === '' && this.table2.temp.allow_error === '') {
  2211. this.$message({ type: 'error', message: '重量/搅拌延时/允许延时偏差不能为空', duration: 2000 })
  2212. return false
  2213. } else if (this.table2.temp.stir_delay === '' && this.table2.temp.allow_error === '') {
  2214. this.$message({ type: 'error', message: '搅拌延时/允许延时偏差不能为空', duration: 2000 })
  2215. return false
  2216. }else if (this.table2.temp.forage_id === '') {
  2217. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2218. return false
  2219. } else if (this.table2.temp.fweight === '') {
  2220. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2221. return false
  2222. } else if (this.table2.temp.stir_delay === '') {
  2223. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2224. return false
  2225. } else if (this.table2.temp.allow_error === '') {
  2226. this.$message({ type: 'error', message: '允许延时偏差不能为空', duration: 2000 })
  2227. return false
  2228. }
  2229. if(parseFloat(this.table2.temp.allow_error) > parseFloat(this.table2.temp.stir_delay)){
  2230. this.$message({ type: 'error', message: '允许延时偏差不可超出搅拌延时', duration: 2000 })
  2231. return false
  2232. }
  2233. if (this.table2.temp.sort !== '') {
  2234. this.table2.temp.sort = this.table2.temp.sort
  2235. } else {
  2236. console.log(this.table2.list.length)
  2237. if (this.table2.list.length == 1) {
  2238. this.table2.temp.sort = 1
  2239. } else {
  2240. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2241. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2242. }
  2243. }
  2244. if (this.table2.parammaps.formula_type_id == 2) {
  2245. if (parseInt(this.table2.temp.preftid) > 0) {
  2246. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2247. return false
  2248. }
  2249. }
  2250. // 校验顺序是否>=0
  2251. var ruleSort = /^\d+$/
  2252. if (!ruleSort.test(this.table2.temp.sort)) {
  2253. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2254. return false
  2255. }
  2256. // 检验重量>0
  2257. this.table2.temp.weight = formatNum(this.table2.temp.weight, 4) // 根据默认参数设置小数位数
  2258. row.weight = formatNum(row.weight, 4)
  2259. if (this.table2.temp.weight == 0) {
  2260. this.$message({ type: 'error', message: '重量请输入正数,最多保留四位小数', duration: 2000 })
  2261. return false
  2262. }
  2263. this.isokDisable = true
  2264. setTimeout(() => {
  2265. this.isokDisable = false
  2266. }, 1000)
  2267. let dateTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
  2268. const url = 'api/v1/ops/feed_formula/feed/edit'
  2269. const data = {
  2270. "feed_formula_id": this.table2.parammaps.id,
  2271. "id":this.table2.temp.id,
  2272. "forage_id": this.table2.temp.forage_id,
  2273. "forage_name": this.table2.temp.forage_name,
  2274. "forage_group_name": this.table2.temp.forage_group_name,
  2275. "sort": parseFloat(this.table2.temp.sort),
  2276. "weight": parseFloat(this.table2.temp.weight),
  2277. "stir_delay": parseFloat(this.table2.temp.stir_delay),
  2278. "allow_error": parseFloat(this.table2.temp.allow_error),
  2279. "is_modify": this.table2.temp.is_modify
  2280. }
  2281. postJson(url, data).then(response => {
  2282. if (response.msg !== 'fail') {
  2283. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2284. this.getList2()
  2285. } else {
  2286. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2287. }
  2288. })
  2289. },
  2290. updateCancel2(row) {
  2291. console.log('点击了详情编辑取消')
  2292. // 饲料组编辑false,不可编辑true
  2293. row.groupEdit = false
  2294. row.groupNoEdit = true
  2295. // 编辑false,不可编辑true
  2296. row.Edit = false
  2297. row.NoEdit = true
  2298. // 新增false,编辑true,编辑保存false
  2299. row.isCreate = false
  2300. row.isUpdate = true
  2301. row.isUpdateSave = false
  2302. this.getList2()
  2303. this.dropState = false
  2304. },
  2305. blurSort(row) {
  2306. if (row.isCreate == true) {
  2307. if (row.sort !== '') {
  2308. for (let i = 1; i < this.table2.list.length; i++) {
  2309. if (this.table2.list[i].sort == parseInt(row.sort)) {
  2310. row.forage_group_name = this.table2.list[i].forage_group_name
  2311. return false
  2312. } else {
  2313. row.forage_group_name = row.forage_name
  2314. }
  2315. }
  2316. } else {
  2317. row.forage_group_name = row.forage_name
  2318. }
  2319. } else if (row.isUpdateSave == true) {
  2320. if (row.sort !== '') {
  2321. for (let i = 0; i < this.table2.list.length; i++) {
  2322. if (this.table2.list[i].sort == row.sort) {
  2323. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  2324. if (this.table2.list[i].id !== row.id) {
  2325. row.isGroupDisabled = true
  2326. row.forage_group_name = this.table2.list[i].forage_group_name
  2327. break
  2328. }
  2329. } else {
  2330. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  2331. row.isGroupDisabled = true
  2332. row.forage_group_name = row.forage_name
  2333. }
  2334. }
  2335. } else {
  2336. row.forage_group_name = row.forage_name
  2337. }
  2338. }
  2339. },
  2340. // 详情删除
  2341. handleRowDelete2(row) {
  2342. console.log('点击了行内删除')
  2343. MessageBox.confirm('是否确认删除此信息?', {
  2344. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2345. }).then(() => {
  2346. const url = 'api/v1/ops/feed_formula/feed/delete'
  2347. const data = {
  2348. "feed_formula_id": row.feed_formula_id,
  2349. "list": [
  2350. {
  2351. "feed_formula_id": row.feed_formula_id,
  2352. "id": row.id,
  2353. "forage_id":row.forage_id,
  2354. "forage_name": row.forage_name,
  2355. "forage_group_name": row.forage_group_name,
  2356. "weight":row.weight,
  2357. "stir_delay":row.stir_delay,
  2358. "allow_error": row.allow_error,
  2359. "sort": row.sort,
  2360. }
  2361. ]
  2362. }
  2363. postJson(url, data).then(response => {
  2364. if (response.msg !== 'fail') {
  2365. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2366. this.getList2()
  2367. } else {
  2368. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2369. }
  2370. })
  2371. }).catch(() => {
  2372. this.$message({ type: 'info', message: '已取消删除' })
  2373. })
  2374. },
  2375. form_delete2() {
  2376. console.log('点击了删除')
  2377. if (this.selectList2.length == 0) {
  2378. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2379. } else {
  2380. MessageBox.confirm('是否确认删除此信息?', {
  2381. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2382. }).then(() => {
  2383. let list = []
  2384. for(let i=0;i<this.selectList2.length;i++){
  2385. let obj = {
  2386. 'feed_formula_id':this.selectList2[i].feed_formula_id,
  2387. 'id':this.selectList2[i].id,
  2388. 'forage_id':this.selectList2[i].forage_id,
  2389. 'forage_name':this.selectList2[i].forage_name,
  2390. 'forage_group_name':this.selectList2[i].forage_group_name,
  2391. 'weight':this.selectList2[i].weight,
  2392. 'stir_delay':this.selectList2[i].stir_delay,
  2393. 'allow_error':this.selectList2[i].allow_error,
  2394. 'sort':this.selectList2[i].sort
  2395. }
  2396. list.push(obj)
  2397. }
  2398. const url = 'api/v1/ops/feed_formula/feed/delete'
  2399. const data = {
  2400. "feed_formula_id": this.table2.parammaps.id,
  2401. "list": list
  2402. }
  2403. postJson(url, data).then(response => {
  2404. if (response.msg !== 'fail') {
  2405. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2406. this.getList2()
  2407. } else {
  2408. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2409. }
  2410. })
  2411. })
  2412. }
  2413. },
  2414. handleSelectionChange2(val) {
  2415. console.log('勾选数据', val)
  2416. this.selectList2 = val
  2417. },
  2418. celldblclick(row, column, cell, event) {
  2419. this.handleUpdate2(row)
  2420. },
  2421. handleEnableChange2(index,row){
  2422. let url = 'api/v1/ops/feed_formula/feed/is_modify'
  2423. let data = {
  2424. "feed_formula_id":row.feed_formula_id,
  2425. "is_modify":row.is_modify,
  2426. 'id':row.id,
  2427. }
  2428. postJson(url,data).then(response => {
  2429. if(response.code == 200){
  2430. this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
  2431. this.getList2()
  2432. }
  2433. })
  2434. },
  2435. // 合成预混料
  2436. handleSyntheticPremix() {
  2437. console.log('点击了合成预混料', this.selectList2)
  2438. this.dialogFull = false
  2439. // if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2440. // this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2441. // return false
  2442. // } else {
  2443. if (this.selectList2.length > 1) {
  2444. for (let i = 0; i < this.selectList2.length; i++) {
  2445. if (parseInt(this.selectList2[i].preftid) > 0) {
  2446. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2447. return false
  2448. }
  2449. }
  2450. if (this.selectList2[0].splitftpreid !== undefined) {
  2451. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2452. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2453. GetDataByName(this.detail.getdataListParm).then(response => {
  2454. if (response.data.list !== null) { // 不为空时得到比对数据
  2455. this.detail.list3 = response.data.list
  2456. const sortList = [] // 声明排序数组
  2457. var fweightSum = 0 // 总重量
  2458. for (let i = 0; i < this.selectList2.length; i++) {
  2459. const obj = {}
  2460. obj.fid = this.selectList2[i].fid
  2461. obj.fweight = this.selectList2[i].fweight
  2462. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2463. sortList.push(obj)
  2464. }
  2465. // 排序
  2466. sortList.sort(function(a, b) {
  2467. return a.fid.localeCompare(b.fid)
  2468. })
  2469. var a = 0
  2470. if (this.detail.list3.length == sortList.length) {
  2471. for (let i = 0; i < this.detail.list3.length; i++) {
  2472. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(3) == (sortList[i].fweight / fweightSum).toFixed(3)) {
  2473. a++
  2474. }
  2475. }
  2476. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2477. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2478. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2479. GetDataByName(this.detail.getdataListParm2).then(response => {
  2480. if (response.data.list !== null) {
  2481. this.detail.dialogStatus = 'SyntheticPremix'
  2482. this.detail.dialogFormVisible = true
  2483. this.detail.list = this.selectList2
  2484. this.detail.list2 = response.data.list
  2485. this.detail.disabled = true
  2486. setTimeout(() => {
  2487. this.detail.listLoading = false
  2488. }, 100)
  2489. } else {
  2490. this.detail.list2 = []
  2491. }
  2492. })
  2493. } else {
  2494. this.detail.dialogStatus = 'SyntheticPremix'
  2495. this.detail.dialogFormVisible = true
  2496. this.detail.list = this.selectList2
  2497. this.detail.disabled = false
  2498. this.detail.list2 = [{ name: '', colour: '#ccc', cattle_category_id: '',cattle_category_name:'', formula_type_name: '预混配方', formula_type_id: '2',data_source_id:1, data_source_name: '自定义', remarks: '', 'is_show': 1 }]
  2499. setTimeout(() => {
  2500. this.detail.listLoading = false
  2501. }, 100)
  2502. }
  2503. } else {
  2504. this.detail.dialogStatus = 'SyntheticPremix'
  2505. this.detail.dialogFormVisible = true
  2506. this.detail.list = this.selectList2
  2507. this.detail.disabled = false
  2508. this.detail.list2 = [{ name: '', colour: '#ccc', cattle_category_id: '', cattle_category_name:'',formula_type_name: '预混配方', formula_type_id: '2', data_source_id:1,data_source_name: '自定义', remarks: '', 'is_show': 1 }]
  2509. setTimeout(() => {
  2510. this.detail.listLoading = false
  2511. }, 100)
  2512. }
  2513. } else {
  2514. this.detail.list3 = []
  2515. this.detail.dialogStatus = 'SyntheticPremix'
  2516. this.detail.dialogFormVisible = true
  2517. this.detail.list = this.selectList2
  2518. this.detail.disabled = false
  2519. this.detail.list2 = [{ name: '', colour: '#ccc', cattle_category_id: '', cattle_category_name:'',formula_type_name: '预混配方', formula_type_id: '2', data_source_id:1,data_source_name: '自定义', remarks: '', 'is_show': 1 }]
  2520. setTimeout(() => {
  2521. this.detail.listLoading = false
  2522. }, 100)
  2523. }
  2524. })
  2525. } else {
  2526. this.detail.dialogStatus = 'SyntheticPremix'
  2527. this.detail.dialogFormVisible = true
  2528. this.detail.list = this.selectList2
  2529. this.detail.disabled = false
  2530. this.detail.list2 = [{ name: '', colour: '#ccc', cattle_category_id: '', cattle_category_name:'',formula_type_name: '预混配方', formula_type_id: '2', data_source_id:1,data_source_name: '自定义', remarks: '', 'is_show': 1 }]
  2531. setTimeout(() => {
  2532. this.detail.listLoading = false
  2533. }, 100)
  2534. }
  2535. } else {
  2536. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2537. return false
  2538. }
  2539. // }
  2540. },
  2541. // 畜生类别
  2542. changeLivestockType2(item) {
  2543. this.detail.list2[0].cattle_category_name = this.livestockTypeList.find(obj => obj.value === item).label
  2544. },
  2545. syntheticPremixData() {
  2546. console.log('点击了合成预混料确认')
  2547. if (this.detail.disabled == true) { // 原预混料
  2548. let sumFweight = 0
  2549. for (let i = 0; i < this.detail.list.length; i++) {
  2550. sumFweight += parseFloat(this.detail.list[i].fweight)
  2551. }
  2552. sumFweight = sumFweight.toFixed(3)
  2553. this.isokDisable = true
  2554. setTimeout(() => {
  2555. this.isokDisable = false
  2556. }, 1000)
  2557. this.requestParam.common = { 'returnmap': '0' }
  2558. this.requestParam.data = []
  2559. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2560. this.requestParam.data[0].children = []
  2561. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2562. pastureid: '@insertSpotList.pastureid',
  2563. id: '@insertSpotList.id'
  2564. }}
  2565. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2566. this.requestParam.data[1].children = []
  2567. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2568. pastureid: Cookies.get('pastureid'),
  2569. ftid: this.table2.getdataListParm.parammaps.ftid,
  2570. fid: this.detail.list2[0].id,
  2571. fname: '@insertSpotList2.tname',
  2572. fweight: sumFweight,
  2573. islockcount: '0',
  2574. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2575. feedgroup: '@insertSpotList2.tname',
  2576. preftid: this.detail.list2[0].id,
  2577. autosecond: this.detail.list[0].autosecond
  2578. }}
  2579. ExecDataByConfig(this.requestParam).then(response => {
  2580. console.log('合成预混料保存发送参数', this.requestParam)
  2581. if (response.msg === 'fail') {
  2582. const tname = new RegExp("key 'tname'")
  2583. if (tname.test(response.data)) {
  2584. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2585. } else {
  2586. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2587. }
  2588. } else {
  2589. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2590. this.detail.dialogFormVisible = false
  2591. this.getList2()
  2592. this.getDownList()
  2593. }
  2594. })
  2595. } else { // 现生成预混料
  2596. if (this.detail.list2[0].name == '' && this.detail.list2[0].cattle_category_id == '') {
  2597. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2598. return false
  2599. } else if (this.detail.list2[0].name == '') {
  2600. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2601. return false
  2602. } else if (this.detail.list2[0].cattle_category_id == '') {
  2603. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2604. return false
  2605. }
  2606. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2607. if (pattern.test(this.detail.list2[0].name)) {
  2608. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2609. return false
  2610. }
  2611. let sumFweight = 0
  2612. for (let i = 0; i < this.detail.list.length; i++) {
  2613. sumFweight += parseFloat(this.detail.list[i].weight)
  2614. }
  2615. sumFweight = sumFweight.toFixed(3)
  2616. console.log(sumFweight)
  2617. this.isokDisable = true
  2618. setTimeout(() => {
  2619. this.isokDisable = false
  2620. }, 1000)
  2621. if (this.detail.list2[0].colour == null) {
  2622. this.detail.list2[0].colour = '#CCCCCC'
  2623. }
  2624. let feed_list = []
  2625. for(let i=0;i<this.detail.list.length;i++){
  2626. let obj = {
  2627. "feed_formula_id":this.detail.list[i].feed_formula_id,
  2628. "forage_id":this.detail.list[i].forage_id,
  2629. "forage_name": this.detail.list[i].forage_name,
  2630. "forage_group_name": this.detail.list[i].forage_group_name,
  2631. "weight": this.detail.list[i].weight,
  2632. "sort": this.detail.list[i].sort
  2633. }
  2634. if(this.detail.list[i].stir_delay){
  2635. obj.stir_delay = this.detail.list[i].stir_delay
  2636. }
  2637. if(this.detail.list[i].allow_error){
  2638. obj.allow_error = this.detail.list[i].allow_error
  2639. }
  2640. feed_list.push(obj)
  2641. }
  2642. let url = 'api/v1/ops/feed_formula/feed/mixed'
  2643. let data = {
  2644. "name": this.detail.list2[0].name,
  2645. "colour": this.detail.list2[0].colour,
  2646. "cattle_category_id": parseFloat(this.detail.list2[0].cattle_category_id),
  2647. "cattle_category_name": this.detail.list2[0].cattle_category_name,
  2648. "formula_type_id": parseFloat(this.detail.list2[0].formula_type_id),
  2649. "formula_type_name": this.detail.list2[0].formula_type_name,
  2650. "data_source_id": parseFloat(this.detail.list2[0].data_source_id),
  2651. "remarks": this.detail.list2[0].remarks,
  2652. "feed_formula_id":feed_list[0].feed_formula_id,
  2653. "feed_list": feed_list
  2654. }
  2655. postJson(url,data).then(response => {
  2656. console.log('合成预混料保存发送参数', this.requestParam)
  2657. if (response.msg === 'fail') {
  2658. const tname = new RegExp("key 'tname'")
  2659. if (tname.test(response.data)) {
  2660. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2661. } else {
  2662. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2663. }
  2664. } else {
  2665. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2666. this.detail.dialogFormVisible = false
  2667. this.getList2()
  2668. this.getDownList()
  2669. }
  2670. })
  2671. }
  2672. },
  2673. getList3(){
  2674. this.table3.listLoading = true
  2675. let url = '/api/v1/ops/feed_formula/edit_record/list'
  2676. let data = {
  2677. "pasture_id":this.table3.parammaps.pasture_id,
  2678. 'feed_formula_id':this.table3.parammaps.id,
  2679. 'feed_formula_id':65
  2680. }
  2681. if(this.table3.parammaps.inputDatetime !== null && this.table3.parammaps.inputDatetime.length > 0){
  2682. data.start_time = parseTime(this.table3.parammaps.inputDatetime[0],'{y}-{m}-{d}')
  2683. data.end_time = parseTime(this.table3.parammaps.inputDatetime[1],'{y}-{m}-{d}')
  2684. }
  2685. postJson(url, data).then(response => {
  2686. if (response.code == 200) {
  2687. this.table3.list = response.data.list
  2688. this.table3.total = response.data.total
  2689. } else {
  2690. this.table3.list = []
  2691. }
  2692. setTimeout(() => {
  2693. this.table3.listLoading = false
  2694. }, 1000)
  2695. })
  2696. },
  2697. handleSearch3(){
  2698. this.getList3()
  2699. },
  2700. // =================================
  2701. getSummaries(param) {
  2702. const { columns, data } = param
  2703. const sums = []
  2704. columns.forEach((column, index) => {
  2705. if (index === 0) {
  2706. sums[index] = '合计'
  2707. return
  2708. }
  2709. if (column.property !== undefined) {
  2710. // 加了prop属性的el-table-column 才能找到column.property
  2711. const values = data.map(item => Number(item[column.property]))
  2712. if (!values.every(value => isNaN(value))) {
  2713. sums[index] = values.reduce((prev, curr) => {
  2714. const value = Number(curr)
  2715. if (!isNaN(value)) {
  2716. return prev + curr // 多行相加
  2717. } else {
  2718. return prev
  2719. }
  2720. }, 0)
  2721. sums[index] = sums[index].toFixed(4) + '(干物质量:' + this.table2.dryweight + ')'
  2722. } else {
  2723. sums[index] = ''
  2724. }
  2725. }
  2726. })
  2727. // console.log(sums, 'sums[index]')
  2728. return sums
  2729. },
  2730. getDryWeight() {
  2731. GetDataByName(this.table2.getDryweightParm).then(response => {
  2732. console.log('干物质数据', response.data.list)
  2733. if (response.data.list[0].dryweight !== undefined) {
  2734. this.table2.dryweight = response.data.list[0].dryweight
  2735. } else {
  2736. this.table2.dryweight = ''
  2737. }
  2738. })
  2739. },
  2740. getTemplateTable2Summaries(param) {
  2741. const { columns, data } = param
  2742. const sums = []
  2743. columns.forEach((column, index) => {
  2744. if (index === 0) {
  2745. sums[index] = '合计'
  2746. return
  2747. }
  2748. const values = data.map(item => Number(item[column.property]))
  2749. if (!values.every(value => isNaN(value))) {
  2750. sums[index] = values.reduce((prev, curr) => {
  2751. const value = Number(curr)
  2752. if (!isNaN(value)) {
  2753. return prev + curr
  2754. } else {
  2755. return prev
  2756. }
  2757. }, 0)
  2758. // 后台待发
  2759. sums[index] += '(干物质量:' + this.template.table2.getdataListParm.parammaps.dryweight + ')'
  2760. } else {
  2761. sums[index] = ''
  2762. }
  2763. })
  2764. return sums
  2765. },
  2766. handleSelectionChange(val) {
  2767. console.log('勾选数据', val)
  2768. this.selectList = val
  2769. },
  2770. // 配方记录
  2771. handleRecipeRecord() {
  2772. console.log('点击了配方记录')
  2773. this.template.dialogStatus = 'RecipeRecord'
  2774. this.dialogFull = false
  2775. this.template.dialogFormVisible = true
  2776. this.template.table.getdataListParm.parammaps.ccname = ''
  2777. this.template.table.getdataListParm.parammaps.fttype = ''
  2778. this.template.table.getdataListParm.parammaps.enable = ''
  2779. this.template.table.getdataListParm.parammaps.tname = ''
  2780. this.template.table.getdataListParm.parammaps.remark = ''
  2781. this.template.table.getdataListParm.parammaps.source = ''
  2782. this.template.table.getdataListParm.offset = 1
  2783. this.getDateList()
  2784. this.isDetailDialog = false
  2785. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  2786. },
  2787. // 历史时间
  2788. getDateList() {
  2789. GetDataByName(this.template.getdataDateParm).then(response => {
  2790. console.log('table数据', response.data.list)
  2791. if (response.data.list !== null) {
  2792. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  2793. this.getTemplateDialogList()
  2794. } else {
  2795. this.template.table.getdataListParm.parammaps.date = ''
  2796. }
  2797. })
  2798. },
  2799. // 配方记录-模板
  2800. getTemplateDialogList() {
  2801. this.template.table.listLoading = true
  2802. GetDataByName(this.template.table.getdataListParm).then(response => {
  2803. console.log('table数据', response.data.list)
  2804. if (response.data.list !== null) {
  2805. this.template.table.list = response.data.list
  2806. this.template.table.pageNum = response.data.pageNum
  2807. this.template.table.pageSize = response.data.pageSize
  2808. this.template.table.total = response.data.total
  2809. } else {
  2810. this.template.table.list = []
  2811. this.template.table2.list = []
  2812. }
  2813. setTimeout(() => {
  2814. this.template.table.listLoading = false
  2815. }, 100)
  2816. })
  2817. },
  2818. handleDialogSearch() {
  2819. this.template.table.getdataListParm.offset = 1
  2820. this.getTemplateDialogList()
  2821. this.arrowDown = true
  2822. this.arrowUp = false
  2823. },
  2824. handleDialogRefresh() {
  2825. this.template.table.getdataListParm.parammaps.ccname = ''
  2826. this.template.table.getdataListParm.parammaps.fttype = ''
  2827. this.template.table.getdataListParm.parammaps.enable = ''
  2828. this.template.table.getdataListParm.parammaps.tname = ''
  2829. this.template.table.getdataListParm.parammaps.remark = ''
  2830. this.template.table.getdataListParm.parammaps.source = ''
  2831. this.template.table.getdataListParm.offset = 1
  2832. this.getTemplateDialogList()
  2833. },
  2834. // 配方记录-模板行点击
  2835. tableRowClickDialog(row, column, event) {
  2836. console.log('配方记录-模板行点击')
  2837. this.isDetailDialog = true
  2838. this.template.table2.getdataListParm.parammaps.date = this.template.table.getdataListParm.parammaps.date
  2839. this.template.table2.getdataListParm.parammaps.version = row.version
  2840. this.template.table2.getdataListParm.parammaps.ftid = row.id
  2841. this.template.table2.getdataListParm.parammaps.dryweight = row.dryweight
  2842. this.myheight2 = document.documentElement.clientHeight - 85 - 265 - 185
  2843. this.getDialogList()
  2844. this.getDownList()
  2845. },
  2846. getDialogList() {
  2847. this.template.table2.listLoading = true
  2848. GetDataByName(this.template.table2.getdataListParm).then(response => {
  2849. console.log('table数据', response.data.list)
  2850. if (response.data.list !== null) {
  2851. this.template.table2.list = response.data.list
  2852. this.template.table2.pageNum = response.data.pageNum
  2853. this.template.table2.pageSize = response.data.pageSize
  2854. this.template.table2.total = response.data.total
  2855. } else {
  2856. this.template.table2.list = []
  2857. }
  2858. this.$nextTick(function() {
  2859. document.querySelector('#detailDialog2').scrollIntoView()
  2860. // window.scrollTo({
  2861. // 'top': this.$refs.detailDialog2.clientHeight
  2862. // })
  2863. })
  2864. setTimeout(() => {
  2865. this.template.table2.listLoading = false
  2866. }, 100)
  2867. })
  2868. },
  2869. handleDialogSearch2() {
  2870. console.log('点击了查询')
  2871. this.arrowDown2 = true
  2872. this.arrowUp2 = false
  2873. this.template.table2.getdataListParm.offset = 1
  2874. this.getDialogList2()
  2875. },
  2876. handleDialogRefresh2() {
  2877. console.log('点击了重置')
  2878. this.template.table2.getdataListParm.parammaps.fname = ''
  2879. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  2880. this.template.table2.getdataListParm.parammaps.fweight = ''
  2881. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  2882. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  2883. this.template.table2.getdataListParm.parammaps.sort = ''
  2884. this.template.table2.getdataListParm.offset = 1
  2885. this.getDialogList2()
  2886. },
  2887. getDialogList2() {
  2888. this.template.table2.listLoading = true
  2889. GetDataByName(this.template.table2.getdataListParm).then(response => {
  2890. console.log('table数据', response.data.list)
  2891. if (response.data.list !== null) {
  2892. this.template.table2.list = response.data.list
  2893. this.template.table2.pageNum = response.data.pageNum
  2894. this.template.table2.pageSize = response.data.pageSize
  2895. this.template.table2.total = response.data.total
  2896. } else {
  2897. this.template.table2.list = []
  2898. }
  2899. this.$nextTick(function() {
  2900. window.scrollTo({
  2901. 'top': this.$refs.templateDialog.clientHeight
  2902. })
  2903. })
  2904. setTimeout(() => {
  2905. this.template.table2.listLoading = false
  2906. }, 100)
  2907. })
  2908. },
  2909. changeDate() {
  2910. this.getTemplateDialogList()
  2911. },
  2912. // 应用
  2913. handleApplication() {
  2914. console.log('点击了应用')
  2915. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  2916. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2917. }).then(() => {
  2918. this.requestParam.name = 'applyFTdate'
  2919. this.requestParam.parammaps = {}
  2920. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  2921. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  2922. PostDataByName(this.requestParam).then(response => {
  2923. if (response.msg === 'fail') {
  2924. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2925. } else {
  2926. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2927. this.getTemplateDialogList()
  2928. this.getList()
  2929. }
  2930. })
  2931. }).catch(() => {
  2932. this.$message({ type: 'info', message: '已取消应用' })
  2933. })
  2934. },
  2935. handleCloseTable2() {
  2936. this.isDetail = false
  2937. this.myheight1 = ''
  2938. this.isEnlarge = true
  2939. },
  2940. handleDialogCloseTable2() {
  2941. this.isDetailDialog = false
  2942. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  2943. },
  2944. // -------------------详情-----------------------------
  2945. // 获取是否显示是否锁定牛头数
  2946. getIsLockCount() {
  2947. GetDataByName(this.lockCount.getdataListParm).then(response => {
  2948. console.log(response.data.list)
  2949. if (response.data.list[0].inforvalue == 0) {
  2950. this.lockCount.isLockCount = false
  2951. } else {
  2952. this.lockCount.isLockCount = true
  2953. }
  2954. })
  2955. },
  2956. // 拆分预混料
  2957. handleSplitPremix(row) {
  2958. console.log('点击了拆分预混料')
  2959. MessageBox.confirm('是否确认拆分当前预混料?', {
  2960. confirmButtonText: '确认',
  2961. cancelButtonText: '取消',
  2962. type: 'warning'
  2963. }).then(() => {
  2964. this.requestParam.name = 'splitFTpre'
  2965. this.requestParam.parammaps = {}
  2966. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2967. this.requestParam.parammaps.preftid = row.preftid
  2968. this.requestParam.parammaps.ftdid = row.id
  2969. this.requestParam.parammaps.pastureid = row.pastureid
  2970. this.requestParam.parammaps.feedgroup = row.feedgroup
  2971. this.requestParam.parammaps.sort = row.sort
  2972. this.requestParam.parammaps.fweight = row.fweight
  2973. PostDataByName(this.requestParam).then(response => {
  2974. if (response.msg === 'fail') {
  2975. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2976. } else {
  2977. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2978. this.getList2()
  2979. }
  2980. })
  2981. }).catch(() => {
  2982. this.$message({
  2983. type: 'info',
  2984. message: '已取消删除'
  2985. })
  2986. })
  2987. },
  2988. handleFormulationEvaluation(row) {
  2989. console.log(row)
  2990. // this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  2991. this.$router.push({
  2992. name: 'FormulationEvaluation',
  2993. params: {
  2994. tname: row.name,
  2995. ftid: row.id,
  2996. pastureid: row.pastureid,
  2997. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  2998. inputDatetime: [new Date('startTime'), new Date('startTime')], // 日期后台待传
  2999. stopTime: parseTime(new Date(), '{y}-{m}-{d}')
  3000. }
  3001. })
  3002. },
  3003. // 使用概况
  3004. handleRowUsageOverview(row) {
  3005. console.log(row)
  3006. this.usageOverview.temp = Object.assign({}, row)
  3007. this.usageOverview.dialogFormVisible = true
  3008. this.textMap.usageOverviewTxt = row.name + '配方使用概况'
  3009. this.usageOverview.dialogStatus = 'usageOverviewTxt'
  3010. this.usageOverview.getdataListParm.parammaps.pastureid = row.pastureid
  3011. this.usageOverview.getdataListParm.parammaps.fitid = row.id
  3012. this.usageOverview.getdataListParm.parammaps.inputDatetime = [new Date(), new Date()]
  3013. this.getRowUsageOverviewList()
  3014. },
  3015. getRowUsageOverviewList() {
  3016. this.usageOverview.listLoading = false
  3017. this.usageOverview.getdataListParm.parammaps.fitid = this.usageOverview.temp.id
  3018. if (this.usageOverview.getdataListParm.parammaps.inputDatetime == null) {
  3019. this.usageOverview.getdataListParm.parammaps.inputDatetime = ''
  3020. this.usageOverview.getdataListParm.parammaps.startTime = ''
  3021. this.usageOverview.getdataListParm.parammaps.stopTime = ''
  3022. } else {
  3023. this.usageOverview.getdataListParm.parammaps.startTime = parseTime(this.usageOverview.getdataListParm.parammaps.inputDatetime[0],'{y}-{m}-{d}')
  3024. this.usageOverview.getdataListParm.parammaps.stopTime = parseTime(this.usageOverview.getdataListParm.parammaps.inputDatetime[1],'{y}-{m}-{d}')
  3025. }
  3026. const url = 'api/v1/ops/feed_formula/usage'
  3027. const data = {
  3028. 'feed_formula_id':this.usageOverview.temp.id,
  3029. 'start_time':this.usageOverview.getdataListParm.parammaps.startTime,
  3030. 'end_time':this.usageOverview.getdataListParm.parammaps.stopTime
  3031. }
  3032. postJson(url, data).then(response => {
  3033. if (response.data !== null) {
  3034. // for (let i = 0; i < response.data.list.length; i++) {
  3035. // if (response.data.list[i].arrList == null) {
  3036. // this.$set(response.data.list[i], 'arrList', [])
  3037. // }
  3038. // }
  3039. this.usageOverview.list = response.data
  3040. this.usageOverview.pageNum = response.data.pageNum
  3041. this.usageOverview.pageSize = response.data.pageSize
  3042. // this.usageOverview.total = response.data.total
  3043. } else {
  3044. this.usageOverview.list = []
  3045. this.usageOverview.total = 0
  3046. }
  3047. console.log(response.data, 'response.data')
  3048. setTimeout(() => {
  3049. this.usageOverview.listLoading = false
  3050. }, 100)
  3051. })
  3052. },
  3053. handleRowUsageOverviewSearch() {
  3054. this.getRowUsageOverviewList()
  3055. },
  3056. handle_feedingefficiency(row){
  3057. console.log(row,'====')
  3058. this.feedingEfficiency.temp = Object.assign({}, row)
  3059. this.textMap.feedingEfficiencyTxt = row.pasture_name
  3060. this.feedingEfficiency.dialogStatus = 'feedingEfficiencyTxt'
  3061. this.getFeedingEfficiencyList()
  3062. },
  3063. getFeedingEfficiencyList(){
  3064. const url = 'api/v1/ops/feed_efficiency/statistics?page='+0+'&page_size='+0
  3065. const data = {
  3066. 'api_name':'getFeedEfficiencyFT',
  3067. 'start_time':this.usageOverview.getdataListParm.parammaps.startTime,
  3068. 'end_time':this.usageOverview.getdataListParm.parammaps.stopTime,
  3069. 'feed_formula_id':this.usageOverview.temp.id,
  3070. 'pasture_id':[this.feedingEfficiency.temp.pasture_id]
  3071. // 'pasture_id':[0]
  3072. }
  3073. postJson(url, data).then(response => {
  3074. if(response.data.list){
  3075. let list = response.data.list
  3076. let dataValue = Object.values(list)
  3077. this.feedingEfficiency.data= dataValue[0]
  3078. this.feedingEfficiency.dialogFormVisible = true
  3079. }else{
  3080. this.feedingEfficiency.data= {}
  3081. this.feedingEfficiency.dialogFormVisible = true
  3082. }
  3083. })
  3084. },
  3085. handle_canceldistributingformula(row){
  3086. MessageBox.confirm('取消后该牧场将无法继续使用该配方,确认取消吗?', {
  3087. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  3088. }).then(() => {
  3089. const url = '/api/v1/ops/feed_formula/cancel/distribute'
  3090. const data = {
  3091. pasture_ids:[row.pasture_id],
  3092. feed_formula_ids:[this.usageOverview.temp.id]
  3093. }
  3094. postJson(url, data).then(response => {
  3095. if (response.msg === 'fail') {
  3096. this.$notify({ title: '失败', message: response.data, type: 'warning', duration: 2000 })
  3097. } else {
  3098. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  3099. // this.getList()
  3100. }
  3101. })
  3102. })
  3103. },
  3104. handleEnlarge() {
  3105. var height = (document.documentElement.clientHeight - 165 + 50).toString() + 'px'
  3106. // var height = (document.documentElement.clientHeight - 165 + 80).toString() + 'px'
  3107. // var height2 = '-' + (document.documentElement.clientHeight - 400).toString() + 'px'
  3108. var height2 = '-' + (this.$refs.template.offsetHeight).toString() + 'px'
  3109. // console.log(this.$refs.detail.offsetHeight)
  3110. // console.log(height2, 'height2')
  3111. this.isEnlarge = false
  3112. this.$refs.detail.style.top = height2
  3113. this.$refs.detail.style.height = height
  3114. this.$refs.appContainer.style.height = height
  3115. this.$refs.table2.style.height = 0
  3116. this.$refs.myContainer.style.posiiton = 'relative'
  3117. this.$refs.detail.style.posiiton = 'absolute'
  3118. },
  3119. handleNarrow() {
  3120. this.isEnlarge = true
  3121. this.$refs.detail.style.top = 0
  3122. this.$refs.detail.style.height = '300px'
  3123. this.$refs.myContainer.style.posiiton = ''
  3124. this.$refs.detail.style.posiiton = ''
  3125. this.$refs.detail.style.zIndex = ''
  3126. },
  3127. handleTakeEffect() {
  3128. if (this.selectList.length == 0) {
  3129. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  3130. } else {
  3131. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  3132. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  3133. }).then(() => {
  3134. let ids = []
  3135. for (let i = 0; i < this.selectList.length; i++) {
  3136. ids.push(this.selectList[i].id)
  3137. }
  3138. var data = {}
  3139. data.parammaps = {}
  3140. data.parammaps.enable = 1
  3141. data.parammaps.id = ids.toString()
  3142. var url = 'authdata/feedtemplet/enable'
  3143. postJson(url,data).then(response => {
  3144. console.log('生效保存发送参数', data)
  3145. if (response.msg === 'fail') {
  3146. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  3147. } else {
  3148. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  3149. this.getList()
  3150. }
  3151. })
  3152. })
  3153. }
  3154. },
  3155. handleDisable() {
  3156. if (this.selectList.length == 0) {
  3157. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  3158. } else {
  3159. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  3160. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  3161. }).then(() => {
  3162. let ids = []
  3163. for (let i = 0; i < this.selectList.length; i++) {
  3164. ids.push(this.selectList[i].id)
  3165. }
  3166. var data = {}
  3167. data.parammaps = {}
  3168. data.parammaps.enable = 0
  3169. data.parammaps.id = ids.toString()
  3170. console.log('禁用', data)
  3171. var url = 'authdata/feedtemplet/enable'
  3172. postJson(url,data).then(response => {
  3173. console.log('禁用保存发送参数', this.requestParam)
  3174. if (response.msg === 'fail') {
  3175. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  3176. } else {
  3177. this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
  3178. this.getList()
  3179. }
  3180. })
  3181. })
  3182. }
  3183. },
  3184. // clickNew(row){
  3185. // console.log('new',row)
  3186. // }
  3187. }
  3188. }
  3189. </script>
  3190. <style lang="scss" scoped>
  3191. // .search{margin-top:10px;height: 40px;}
  3192. // .operation{height: 50px;}
  3193. .table{margin-top:5px;}
  3194. .table2{margin-top:10px;}
  3195. $width:350px;
  3196. $left:325px;
  3197. .selectInput{
  3198. position: relative;
  3199. display: inline-block;
  3200. .Input{width: $width;position: relative;}
  3201. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  3202. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  3203. .selectUl{
  3204. height:220px;overflow-y: auto;z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  3205. li{
  3206. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  3207. a{float:left;width: 80px;}
  3208. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  3209. }
  3210. }
  3211. }
  3212. .template{
  3213. background: #fff;
  3214. position: relative;
  3215. }
  3216. .app-container{background: #fff;}
  3217. .detail{
  3218. background: #fff;
  3219. overflow-y: hidden;
  3220. overflow-x: hidden;
  3221. // position: fixed;
  3222. // bottom: 0;
  3223. // right:0;
  3224. z-index: 3;
  3225. // width: calc(100% - 210px);
  3226. position: relative;
  3227. }
  3228. .hide2{float: right;right:0;}
  3229. .templateDialog{
  3230. background: #fff;
  3231. position: relative;
  3232. }
  3233. .detailDialog{
  3234. background: #fff;
  3235. position: relative;
  3236. }
  3237. .hide{float: right;margin-right: 60px;}
  3238. .content div{
  3239. text-align: center;
  3240. line-height: 30px;
  3241. border-bottom: 1px solid #eee;
  3242. }
  3243. .content div .title{
  3244. width:250px;text-align: right;display: inline-block;margin-right: 10px;
  3245. }
  3246. .item {
  3247. margin-top: 10px;
  3248. margin-right: 40px;
  3249. }
  3250. .new{
  3251. background: #01BE80;
  3252. padding: 5px 5px;
  3253. margin-left: 5px;
  3254. border-radius: 8px;
  3255. color:#fff;
  3256. cursor: pointer;
  3257. }
  3258. </style>
  3259. <style>
  3260. .el-color-dropdown__main-wrapper{display: none !important;}
  3261. .el-color-dropdown__value{display: none !important;}
  3262. .el-color-dropdown__btns .el-button--text{display: none !important;}
  3263. </style>