3f59fcf576037a7e7996207f59410f39d9c740af.svn-base 128 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788
  1. <template>
  2. <div ref="appContainer" class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <div class="recipeTemplate">
  6. <p>配方模板表</p>
  7. </div>
  8. <div class="search">
  9. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  10. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  11. </el-select>
  12. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  13. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  14. </el-select>
  15. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  16. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  17. </el-select>
  18. <div ref="selectInput" class="filter-item selectInput">
  19. <el-input v-model="table.getdataListParm.parammaps.all" type="text" placeholder="请点击选择搜索条件" class="Input" />
  20. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  21. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  22. <ul v-if="arrowUp" class="selectUl">
  23. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" clearable style="width: 245px;" /></li>
  24. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" clearable style="width: 245px;" /></li>
  25. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" clearable style="width: 245px;" /></li>
  26. <li>
  27. <div style="float: right;">
  28. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  29. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  30. </div>
  31. </li>
  32. </ul>
  33. </div>
  34. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  35. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  36. </div>
  37. <div class="operation">
  38. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  39. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  40. <el-button v-if="isRoleEdit" class="copy" icon="el-icon-copy-document" @click="handleCopy">复制</el-button>
  41. <el-upload style="float: right;margin-right: 15px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  42. <el-button v-if="isRoleEdit" class="export" icon="el-icon-download" style="float: right;">导入</el-button>
  43. </el-upload>
  44. <el-dropdown style="float: right;">
  45. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  46. <el-dropdown-menu slot="dropdown">
  47. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  48. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. <el-button class="export" style="float: right;" @click="handleRecipeRecord">配方记录</el-button>
  52. </div>
  53. <div ref="table" class="table">
  54. <el-table
  55. :key="table.tableKey"
  56. v-loading="table.listLoading"
  57. element-loading-text="给我一点时间"
  58. :data="table.list"
  59. border
  60. fit
  61. highlight-current-row
  62. style="width: 98%;"
  63. :row-style="rowStyle"
  64. :cell-style="cellStyle"
  65. class="elTable table-fixed"
  66. :height="myheight"
  67. @row-click="tableRowClick"
  68. @selection-change="handleSelectionChange"
  69. >
  70. <el-table-column type="selection" align="center" width="50" />
  71. <el-table-column label="序号" align="center" type="index" width="50px" />
  72. <el-table-column label="配方名称" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  75. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="配方编码" min-width="90px" align="center">
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.NoEdit">{{ scope.row.tcode }}</span>
  81. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tcode" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="配方颜色" min-width="70px" align="center">
  85. <template slot-scope="scope">
  86. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="scope.row.NoEdit" />
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="牲畜类别" min-width="130px" align="center">
  90. <template slot-scope="scope">
  91. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  92. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  93. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  94. </el-select>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="配方类型" min-width="130px" align="center">
  98. <template slot-scope="scope">
  99. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  100. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  101. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  102. </el-select>
  103. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  104. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  105. </el-select>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="来源" min-width="90px" align="center">
  109. <template slot-scope="scope">
  110. <span>{{ scope.row.source }}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="备注" min-width="90px" align="center">
  114. <template slot-scope="scope">
  115. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  116. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="版本号" min-width="90px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.version }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="是否启用" min-width="90px" align="center">
  125. <template slot-scope="scope">
  126. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  130. <template slot-scope="{row}">
  131. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  132. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  133. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  134. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  135. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  136. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  137. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  138. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  139. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  140. <span v-if="row.NoEdit && isRoleEdit && ispastureuse ==0" icon="el-icon-data-line" class="centerSpan">|</span>
  141. <el-button v-if="row.NoEdit && isRoleEdit && ispastureuse==0" icon="el-icon-data-line" class="miniSuccess" @click="handleFormulationEvaluation(row)" />
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. </div>
  146. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;margin-bottom: 10px;font-size: 14px;">共{{ table.total }}条</span>
  147. </div>
  148. <!-- 配方详情表 -->
  149. <div v-if="isDetail" ref="detail" class="detail">
  150. <div class="recipeTemplate">
  151. <p>配方详情表</p>
  152. </div>
  153. <div class="operation">
  154. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-plus" class="success" @click="handleCreate2">新增</el-button>
  155. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-delete" class="danger" @click="handleDelete2">删除</el-button>
  156. <el-button v-if="isRoleEdit" style="float: left;" class="success" icon="el-icon-takeaway-box" @click="handleSyntheticPremix">合成预混料</el-button>
  157. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  158. <div v-else style="float: left;margin-left: 10px;">
  159. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  160. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  161. </div>
  162. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  163. <el-input v-model="table2.getdataListParm.parammaps.all" type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  164. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  165. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  166. <ul v-if="arrowUp2" class="selectUl">
  167. <li>
  168. <a style="width: 130px;">饲料名称</a>
  169. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:190px;">
  170. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  171. </el-select>
  172. </li>
  173. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 190px;" /></li>
  174. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 190px;" /></li>
  175. <li>
  176. <a style="width: 130px;">搅拌延时</a>
  177. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:190px;" clearable>
  178. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  179. </el-select>
  180. </li>
  181. <li>
  182. <a style="width: 130px;">是否锁定牛头数比例</a>
  183. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:190px;" clearable>
  184. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  185. </el-select>
  186. </li>
  187. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 190px;" /></li>
  188. <li>
  189. <div style="float: right;">
  190. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  191. <el-button class="miniPrimary" @click="handleSearch2">搜索</el-button>
  192. </div>
  193. </li>
  194. </ul>
  195. </div>
  196. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  197. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  198. <el-button class="hide" @click="handleCloseTable2">隐藏</el-button>
  199. </div>
  200. <div class="table2" style="height: 250px;overflow-y: auto;">
  201. <el-table
  202. id="table2"
  203. ref="table2"
  204. :key="table2.tableKey"
  205. v-loading="table2.listLoading"
  206. element-loading-text="给我一点时间"
  207. :data="table2.list"
  208. border
  209. fit
  210. highlight-current-row
  211. style="width: 98%;"
  212. :row-style="rowStyle"
  213. :cell-style="cellStyle"
  214. class="elTable"
  215. row-key="id"
  216. show-summary
  217. :summary-method="getSummaries"
  218. @selection-change="handleSelectionChange2"
  219. >
  220. <el-table-column type="selection" width="50" />
  221. <el-table-column label="序号" align="center" type="index" width="50px" />
  222. <el-table-column label="饲料组" min-width="120px" align="center">
  223. <template slot-scope="scope">
  224. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  225. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  226. </template>
  227. </el-table-column>
  228. <el-table-column label="饲料名称" min-width="120px" align="center">
  229. <template slot-scope="scope">
  230. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  231. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  232. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  233. </el-select>
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="重量(KG)" prop="fweight" width="120px" align="center">
  237. <template slot-scope="scope">
  238. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  239. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="搅拌延时(min)" min-width="80px" align="center">
  243. <template slot-scope="scope">
  244. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  245. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  246. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  247. </el-select>
  248. </template>
  249. </el-table-column>
  250. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="80px" align="center">
  251. <template slot-scope="scope">
  252. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  253. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  254. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  255. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  256. </el-select>
  257. </template>
  258. </el-table-column>
  259. <el-table-column label="顺序" min-width="70px" align="center">
  260. <template slot-scope="scope">
  261. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  262. <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)" />
  263. </template>
  264. </el-table-column>
  265. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  266. <template slot-scope="{row}">
  267. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData2(row)" />
  268. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  269. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  270. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  271. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  272. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  273. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData2(row)" />
  274. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  275. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel2(row)" />
  276. <span v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" class="centerSpan">|</span>
  277. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" icon="el-icon-connection" class="miniSuccess" @click="handleSplitPremix(row)" />
  278. </template>
  279. </el-table-column>
  280. </el-table>
  281. </div>
  282. </div>
  283. <!-- 配方模板表 -->
  284. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  285. <template slot="title">
  286. <div class="avue-crud__dialog__header">
  287. <span class="el-dialog__title">
  288. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  289. {{ textMap[template.dialogStatus] }}
  290. </span>
  291. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  292. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  293. <svg-icon v-else icon-class="fullscreen" />
  294. </div>
  295. </div>
  296. </template>
  297. <div class="dialogMinHeight" style="overflow-y: auto;margin-bottom: 0px;overflow-x: hidden;">
  298. <div ref="templateDialog" class="templateDialog">
  299. <div class="recipeTemplate">
  300. <p>配方模板表</p>
  301. </div>
  302. <div class="operation">
  303. <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" />
  304. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  305. </div>
  306. <div class="search">
  307. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  308. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  309. </el-select>
  310. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  311. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  312. </el-select>
  313. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  314. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  315. </el-select>
  316. <div ref="selectInput" class="filter-item selectInput">
  317. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  318. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  319. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  320. <ul v-if="arrowUp" class="selectUl">
  321. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  322. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  323. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  324. <li>
  325. <div style="float: right;">
  326. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  327. <el-button class="miniPrimary" @click="handleDialogSearch">搜索</el-button>
  328. </div>
  329. </li>
  330. </ul>
  331. </div>
  332. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  333. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  334. </div>
  335. <div class="table">
  336. <el-table
  337. :key="template.table.tableKey"
  338. v-loading="template.table.listLoading"
  339. element-loading-text="给我一点时间"
  340. :data="template.table.list"
  341. border
  342. fit
  343. highlight-current-row
  344. style="width: 98%;"
  345. :row-style="rowStyle"
  346. :height="myheight2"
  347. :cell-style="cellStyle"
  348. class="elTable table-fixed"
  349. @row-click="tableRowClickDialog"
  350. >
  351. <el-table-column v-if="template.dialogStatus == 'RecipeRecord'" label="序号" align="center" type="index" width="50px" />
  352. <el-table-column v-else label="序号" align="center" type="index" width="50px">
  353. <template slot-scope="scope">
  354. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  355. </template>
  356. </el-table-column>
  357. <el-table-column label="配方名称" min-width="130px" align="center">
  358. <template slot-scope="scope">
  359. <span>{{ scope.row.tname }}</span>
  360. </template>
  361. </el-table-column>
  362. <el-table-column label="配方编码" min-width="90px" align="center">
  363. <template slot-scope="scope">
  364. <span>{{ scope.row.tcode }}</span>
  365. </template>
  366. </el-table-column>
  367. <el-table-column label="配方颜色" min-width="110px" align="center">
  368. <template slot-scope="scope">
  369. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" />
  370. </template>
  371. </el-table-column>
  372. <el-table-column label="牲畜类别" min-width="110px" align="center">
  373. <template slot-scope="scope">
  374. <span>{{ scope.row.ccname }}</span>
  375. </template>
  376. </el-table-column>
  377. <el-table-column label="配方类型" min-width="110px" align="center">
  378. <template slot-scope="scope">
  379. <span>{{ scope.row.fttype }}</span>
  380. </template>
  381. </el-table-column>
  382. <el-table-column label="来源" min-width="90px" align="center">
  383. <template slot-scope="scope">
  384. <span>{{ scope.row.source }}</span>
  385. </template>
  386. </el-table-column>
  387. <el-table-column label="备注" min-width="90px" align="center">
  388. <template slot-scope="scope">
  389. <span>{{ scope.row.remark }}</span>
  390. </template>
  391. </el-table-column>
  392. <el-table-column label="版本号" min-width="90px" align="center">
  393. <template slot-scope="scope">
  394. <span>{{ scope.row.version }}</span>
  395. </template>
  396. </el-table-column>
  397. <el-table-column label="版本时间" min-width="90px" align="center">
  398. <template slot-scope="scope">
  399. <span>{{ scope.row.versiontime }}</span>
  400. </template>
  401. </el-table-column>
  402. <el-table-column label="是否启用" min-width="90px" align="center">
  403. <template slot-scope="scope">
  404. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  405. </template>
  406. </el-table-column>
  407. </el-table>
  408. </div>
  409. </div>
  410. <div v-if="isDetailDialog" id="detailDialog2" ref="detailDialog2" class="detailDialog" style="margin-top: 30px;height: 200px;overflow-y: auto;overflow-x: hidden;">
  411. <div class="recipeTemplate">
  412. <p>配方详情表</p>
  413. </div>
  414. <div class="operation">
  415. <div ref="selectInput2" class="filter-item selectInput">
  416. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  417. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  418. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  419. <ul v-if="arrowUp2" class="selectUl">
  420. <li>
  421. <a style="width: 130px;">饲料名称</a>
  422. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  423. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  424. </el-select>
  425. </li>
  426. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  427. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  428. <li>
  429. <a style="width: 130px;">搅拌延时</a>
  430. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  431. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  432. </el-select>
  433. </li>
  434. <li>
  435. <a style="width: 130px;">是否锁定牛头数比例</a>
  436. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  437. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  438. </el-select>
  439. </li>
  440. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  441. <li>
  442. <div style="float: right;">
  443. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  444. <el-button class="miniPrimary" @click="handleDialogSearch2">搜索</el-button>
  445. </div>
  446. </li>
  447. </ul>
  448. </div>
  449. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  450. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  451. <el-button class="hide" @click="handleDialogCloseTable2">隐藏</el-button>
  452. </div>
  453. <div class="table2">
  454. <el-table
  455. id="templateTable2"
  456. :key="template.table2.tableKey"
  457. v-loading="template.table2.listLoading"
  458. element-loading-text="给我一点时间"
  459. :data="template.table2.list"
  460. border
  461. fit
  462. highlight-current-row
  463. style="width: 98%;"
  464. :summary-method="getTemplateTable2Summaries"
  465. show-summary
  466. :row-style="rowStyle"
  467. :cell-style="cellStyle"
  468. class="elTable table-fixed"
  469. row-key="id"
  470. >
  471. <el-table-column label="饲料组" min-width="130px" align="center">
  472. <template slot-scope="scope">
  473. <span>{{ scope.row.feedgroup }}</span>
  474. </template>
  475. </el-table-column>
  476. <el-table-column label="饲料名称" min-width="130px" align="center">
  477. <template slot-scope="scope">
  478. <span>{{ scope.row.fname }}</span>
  479. </template>
  480. </el-table-column>
  481. <el-table-column label="重量(KG)" prop="fweight" min-width="200px" align="center">
  482. <template slot-scope="scope">
  483. <span>{{ scope.row.fweight }}</span>
  484. </template>
  485. </el-table-column>
  486. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  487. <template slot-scope="scope">
  488. <span>{{ scope.row.autosecondname }}</span>
  489. </template>
  490. </el-table-column>
  491. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  492. <template slot-scope="scope">
  493. <span v-if="scope.row.islockcount == '0'">否</span>
  494. <span v-if="scope.row.islockcount == '1'">是</span>
  495. </template>
  496. </el-table-column>
  497. <el-table-column label="顺序" min-width="130px" align="center">
  498. <template slot-scope="scope">
  499. <span>{{ scope.row.sort }}</span>
  500. </template>
  501. </el-table-column>
  502. </el-table>
  503. </div>
  504. </div>
  505. </div>
  506. <div slot="footer" class="dialog-footer">
  507. <el-button class="cancelClose cancelClose1" @click="template.dialogFormVisible = false; ">关闭</el-button>
  508. </div>
  509. </el-dialog>
  510. <!-- 合成预混料 -->
  511. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  512. <template slot="title">
  513. <div class="avue-crud__dialog__header">
  514. <span class="el-dialog__title">
  515. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  516. {{ textMap[detail.dialogStatus] }}
  517. </span>
  518. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  519. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  520. <svg-icon v-else icon-class="fullscreen" />
  521. </div>
  522. </div>
  523. </template>
  524. <div class="detailDialog">
  525. <h2>饲料</h2>
  526. <div class="table1">
  527. <el-table
  528. :key="detail.tableKey"
  529. v-loading="detail.listLoading"
  530. element-loading-text="给我一点时间"
  531. :data="detail.list"
  532. fit
  533. highlight-current-row
  534. style="width: 100%;"
  535. :row-style="rowStyle"
  536. :cell-style="cellStyle"
  537. class="elTable table-fixed"
  538. show-summary
  539. >
  540. <el-table-column label="序号" align="center" type="index" width="50px" />
  541. <el-table-column label="饲料名称" min-width="130px" align="center">
  542. <template slot-scope="scope">
  543. <span>{{ scope.row.fname }}</span>
  544. </template>
  545. </el-table-column>
  546. <el-table-column prop="fweight" label="重量(KG)" />
  547. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  548. <template slot-scope="scope">
  549. <span>{{ scope.row.autosecond }}</span>
  550. </template>
  551. </el-table-column>
  552. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  553. <template slot-scope="scope">
  554. <span v-if="scope.row.islockcount == '0'">否</span>
  555. <span v-if="scope.row.islockcount == '1'">是</span>
  556. </template>
  557. </el-table-column>
  558. <el-table-column label="顺序" min-width="110px" align="center">
  559. <template slot-scope="scope">
  560. <span>{{ scope.row.sort }}</span>
  561. </template>
  562. </el-table-column>
  563. </el-table>
  564. </div>
  565. <h2>合成预混料</h2>
  566. <div class="table2" style="margin-bottom: 50px;">
  567. <el-table
  568. :key="detail.tableKey2"
  569. v-loading="detail.listLoading2"
  570. element-loading-text="给我一点时间"
  571. :data="detail.list2"
  572. border
  573. fit
  574. highlight-current-row
  575. style="width: 100%;"
  576. :row-style="rowStyle"
  577. :cell-style="cellStyle"
  578. class="elTable table-fixed"
  579. >
  580. <el-table-column label="配方名称" min-width="130px" align="center">
  581. <template slot-scope="scope">
  582. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  583. </template>
  584. </el-table-column>
  585. <el-table-column label="配方颜色" min-width="130px" align="center">
  586. <template slot-scope="scope">
  587. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="detail.disabled" />
  588. </template>
  589. </el-table-column>
  590. <el-table-column label="牲畜类别" min-width="130px" align="center">
  591. <template slot-scope="scope">
  592. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  593. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  594. </el-select>
  595. </template>
  596. </el-table-column>
  597. <el-table-column label="配方类型" min-width="110px" align="center">
  598. <template slot-scope="scope">
  599. <span>{{ scope.row.fttype }}</span>
  600. </template>
  601. </el-table-column>
  602. <el-table-column label="来源" min-width="110px" align="center">
  603. <template slot-scope="scope">
  604. <span>{{ scope.row.source }}</span>
  605. </template>
  606. </el-table-column>
  607. <el-table-column label="备注" min-width="130px" align="center">
  608. <template slot-scope="scope">
  609. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  610. </template>
  611. </el-table-column>
  612. <el-table-column label="是否启用" min-width="130px" align="center">
  613. <template slot-scope="scope">
  614. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  615. </template>
  616. </el-table-column>
  617. </el-table>
  618. </div>
  619. <div slot="footer" class="dialog-footer">
  620. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  621. <el-button class="save" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  622. </div>
  623. </div>
  624. </el-dialog>
  625. <!-- 历史记录 -->
  626. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  627. <div class="historyRecord">
  628. <keep-alive>
  629. <component :is="historyRecord.myComponent" ref="historyRecord" />
  630. </keep-alive>
  631. </div>
  632. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  633. <el-button class="cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  634. </div>
  635. </el-dialog>
  636. </div>
  637. </template>
  638. <script>
  639. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, checkButtons, ExecDataByConfig, formatNum } from '@/api/common'
  640. import Sortable from 'sortablejs'
  641. import { MessageBox } from 'element-ui'
  642. import Cookies from 'js-cookie'
  643. import { json2excel } from '@/utils/index.js'
  644. import axios from 'axios'
  645. import { getToken } from '@/utils/auth'
  646. import { parseTime } from '@/utils/index.js'
  647. export default {
  648. name: 'RecipeTemplate',
  649. data() {
  650. return {
  651. dialogFull: false,
  652. predefineColors: [
  653. '#E57373', '#F06292', '#BA68C8', '#9575CD', '#7986CB', '#64B5F6', '#4FC3F7', '#4DD0E1', '#4DB6AC', '#81C784', '#AED581', '#DCE775', '#FFF176', '#FFD54F', '#FFB74D', '#FF8A65', '#A1887F', '#E0E0E0', '#90A4AE'
  654. ],
  655. isRoleEdit: [],
  656. myheight: '',
  657. requestParams: [
  658. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  659. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  660. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  661. ],
  662. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  663. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  664. livestockTypeList: [], // 牲畜类别
  665. formulaTypeList: [], // 配方类型
  666. feedNameList: [], // 饲料名称
  667. 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' }], // 搅拌延时
  668. 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' }], // 请选择历史记录时间
  669. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  670. arrowDown: true,
  671. arrowUp: false,
  672. ispastureuse: Cookies.get('ispastureuse'),
  673. table: {
  674. getdataListParm: {
  675. name: 'getFTList',
  676. page: 1,
  677. offset: 1,
  678. pagecount: '',
  679. returntype: 'Map',
  680. parammaps: {
  681. pastureid: Cookies.get('pastureid'),
  682. tname: '',
  683. ccid: '',
  684. ccname: '',
  685. fttypeid: '',
  686. fttype: '',
  687. remark: '',
  688. enable: '',
  689. source: ''
  690. }
  691. },
  692. tableKey: 0,
  693. list: [],
  694. total: 0,
  695. listLoading: true,
  696. temp: {}
  697. },
  698. lockCount: {
  699. getdataListParm: {
  700. name: 'getSysoptEnable',
  701. page: 1,
  702. offset: 1,
  703. pagecount: 30,
  704. returntype: 'Map',
  705. parammaps: {
  706. pastureid: Cookies.get('pastureid'),
  707. inforname: 'isLockCount'
  708. }
  709. },
  710. isLockCount: false // 是否显示是否锁定牛头数比例
  711. },
  712. isDetail: false,
  713. arrowDown2: true,
  714. arrowUp2: false,
  715. table2: {
  716. getDryweightParm: {
  717. name: 'getFTdryweight',
  718. page: 1,
  719. offset: 1,
  720. pagecount: 10,
  721. returntype: 'Map',
  722. parammaps: {
  723. pastureid: '',
  724. ftid: ''
  725. }
  726. },
  727. dryweight: '',
  728. getdataListParm: {
  729. name: 'getFTdetailList',
  730. page: 1,
  731. offset: 1,
  732. pagecount: '',
  733. returntype: 'Map',
  734. parammaps: {
  735. pastureid: Cookies.get('pastureid'),
  736. fname: '',
  737. feedgroup: '',
  738. fweight: '',
  739. autosecondname: '',
  740. islockcount: '',
  741. sort: ''
  742. }
  743. },
  744. tableKey: 0,
  745. list: [],
  746. total: 0,
  747. listLoading: true,
  748. temp: {}
  749. },
  750. isDetailDialog: false,
  751. template: {
  752. dialogFormVisible: false,
  753. dialogStatus: '',
  754. table: {
  755. getdataListParm: {
  756. name: 'getFTListDate',
  757. page: 1,
  758. offset: 1,
  759. pagecount: '',
  760. returntype: 'Map',
  761. parammaps: {
  762. pastureid: Cookies.get('pastureid'),
  763. tname: '',
  764. ccid: '',
  765. ccname: '',
  766. fttype: '',
  767. remark: '',
  768. enable: '',
  769. date: '',
  770. source: ''
  771. }
  772. },
  773. tableKey: 0,
  774. total: 0,
  775. listLoading: true,
  776. list: []
  777. },
  778. table2: {
  779. getdataListParm: {
  780. name: 'getFTdetailListDate',
  781. page: 1,
  782. offset: 1,
  783. pagecount: 10,
  784. returntype: 'Map',
  785. parammaps: {
  786. pastureid: Cookies.get('pastureid'),
  787. fname: '',
  788. fweight: '',
  789. islockcount: '',
  790. sort: '',
  791. feedgroup: '',
  792. autosecondname: ''
  793. }
  794. },
  795. tableKey: 0,
  796. total: 0,
  797. listLoading: true,
  798. list: []
  799. },
  800. // 历史日期
  801. getdataDateParm: {
  802. name: 'getFTMaxDate',
  803. page: 1,
  804. offset: 1,
  805. pagecount: 10,
  806. returntype: 'Map',
  807. parammaps: {
  808. pastureid: Cookies.get('pastureid')
  809. }
  810. }
  811. },
  812. isOrder: true,
  813. detail: {
  814. dialogFormVisible: false,
  815. dialogStatus: '',
  816. tableKey: 0,
  817. total: 0,
  818. listLoading: true,
  819. list: [],
  820. tableKey2: 0,
  821. total2: 0,
  822. listLoading2: false,
  823. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  824. getdataListParm: {
  825. name: 'getFTDetailCompare',
  826. page: 1,
  827. offset: 1,
  828. pagecount: 10,
  829. returntype: 'Map',
  830. parammaps: {}
  831. },
  832. list3: [],
  833. disabled: false,
  834. getdataListParm2: {
  835. name: 'getFTCompare',
  836. page: 1,
  837. offset: 1,
  838. pagecount: 10,
  839. returntype: 'Map',
  840. parammaps: {}
  841. }
  842. },
  843. selectList: [],
  844. selectList2: [],
  845. textMap: {
  846. RecipeRecord: '配方记录',
  847. SyntheticPremix: '合成预混料',
  848. historyRecord: '历史记录',
  849. detail: '饲料详情'
  850. },
  851. requestParam: {},
  852. download: {
  853. getdataListParm: {
  854. name: 'getFTList',
  855. page: 1,
  856. offset: 1,
  857. pagecount: 0,
  858. returntype: 'Map',
  859. parammaps: {
  860. pastureid: Cookies.get('pastureid'),
  861. tname: '',
  862. ccid: '',
  863. ccname: '',
  864. fttypeid: '',
  865. fttype: '',
  866. remark: '',
  867. enable: ''
  868. }
  869. },
  870. list: []
  871. },
  872. historyRecord: {
  873. dialogStatus: '',
  874. dialogFormVisible: false
  875. },
  876. isokDisable: false,
  877. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  878. cellStyle: { padding: 0 + 'px' },
  879. dropState: false,
  880. myheight2: 0,
  881. height: 0
  882. }
  883. },
  884. computed: {
  885. // 设置请求头
  886. headers() {
  887. return {
  888. token: getToken()
  889. }
  890. },
  891. uploadData() {
  892. return {
  893. name: 'checkfttype,checkbigcowclass,checkFeed,insertFTUpload,insertFTdetailUpload',
  894. importParams: '配方名称,牲畜类别,配方类型,备注,饲料组,饲料名称,重量(kg),搅拌延时(min),是否锁定牛头数比例',
  895. sheetname: 'Sheet1',
  896. // 登录牧场
  897. pastureid: Cookies.get('pastureid'),
  898. // 日期参数
  899. dateParams: '',
  900. // 必填参数
  901. requiredParams: '配方名称,牲畜类别,配方类型,饲料名称,重量(kg),搅拌延时(min),是否锁定牛头数比例',
  902. // 为数值的参数
  903. numParams: '重量(kg),搅拌延时(min)'
  904. }
  905. },
  906. // 设置上传地址
  907. uploadExcelUrl() {
  908. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  909. }
  910. },
  911. mounted() {
  912. document.addEventListener('click', (e) => {
  913. if (this.$refs.selectInput !== undefined) {
  914. if (!this.$refs.selectInput.contains(e.target)) {
  915. this.arrowDown = true
  916. this.arrowUp = false
  917. } else {
  918. this.arrowDown = false
  919. this.arrowUp = true
  920. }
  921. }
  922. if (this.$refs.selectInput2 !== undefined) {
  923. if (!this.$refs.selectInput2.contains(e.target)) {
  924. this.arrowDown2 = true
  925. this.arrowUp2 = false
  926. } else {
  927. this.arrowDown2 = false
  928. this.arrowUp2 = true
  929. }
  930. }
  931. })
  932. },
  933. created() {
  934. this.getList()
  935. this.getButtons()
  936. this.getDownList()
  937. this.getIsLockCount()
  938. },
  939. methods: {
  940. getButtons() {
  941. const Edit = 'FormulationEvaluation'
  942. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  943. this.isRoleEdit = isRoleEdit
  944. },
  945. getSummaries(param) {
  946. console.log(param, '====')
  947. const { columns, data } = param
  948. const sums = []
  949. columns.forEach((column, index) => {
  950. if (index === 0) {
  951. sums[index] = '合计'
  952. return
  953. }
  954. if (column.property !== undefined) {
  955. // 加了prop属性的el-table-column 才能找到column.property
  956. const values = data.map(item => Number(item[column.property]))
  957. if (!values.every(value => isNaN(value))) {
  958. sums[index] = values.reduce((prev, curr) => {
  959. const value = Number(curr)
  960. if (!isNaN(value)) {
  961. return prev + curr // 多行相加
  962. } else {
  963. return prev
  964. }
  965. }, 0)
  966. sums[index] = sums[index].toFixed(parseInt(Cookies.get('decimal'))) + '(干物质量:' + this.table2.dryweight + ')'
  967. } else {
  968. sums[index] = ''
  969. }
  970. }
  971. })
  972. // console.log(sums, 'sums[index]')
  973. return sums
  974. },
  975. getDryWeight() {
  976. GetDataByName(this.table2.getDryweightParm).then(response => {
  977. console.log('table数据', response.data.list)
  978. if (response.data.list[0].dryweight !== undefined) {
  979. this.table2.dryweight = response.data.list[0].dryweight
  980. } else {
  981. this.table2.dryweight = ''
  982. }
  983. })
  984. },
  985. getTemplateTable2Summaries(param) {
  986. console.log(param, '====')
  987. const { columns, data } = param
  988. const sums = []
  989. columns.forEach((column, index) => {
  990. if (index === 0) {
  991. sums[index] = '合计'
  992. return
  993. }
  994. const values = data.map(item => Number(item[column.property]))
  995. if (!values.every(value => isNaN(value))) {
  996. sums[index] = values.reduce((prev, curr) => {
  997. const value = Number(curr)
  998. if (!isNaN(value)) {
  999. return prev + curr
  1000. } else {
  1001. return prev
  1002. }
  1003. }, 0)
  1004. // 后台待发
  1005. sums[index] += '(干物质量:' + this.template.table2.getdataListParm.parammaps.dryweight + ')'
  1006. } else {
  1007. sums[index] = ''
  1008. }
  1009. })
  1010. return sums
  1011. },
  1012. // handleHistory() {
  1013. // MessageBox.confirm('是否确认生成历史?', {
  1014. // confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1015. // }).then(() => {
  1016. // this.requestParam.name = 'creatFTdate'
  1017. // this.requestParam.parammaps = {}
  1018. // this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1019. // PostDataByName(this.requestParam).then(response => {
  1020. // console.log('生成历史保存发送参数', this.requestParam)
  1021. // if (response.msg !== 'fail') {
  1022. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1023. // } else {
  1024. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1025. // }
  1026. // })
  1027. // })
  1028. // },
  1029. getDownList() {
  1030. GetDataByNames(this.requestParams).then(response => {
  1031. this.livestockTypeList = response.data.getDictByName.list
  1032. this.formulaTypeList = response.data.getDictByName2.list
  1033. this.feedNameList = response.data.getFeedAndPre.list
  1034. })
  1035. },
  1036. // -------------------模板-----------------------------
  1037. getList() {
  1038. this.table.listLoading = true
  1039. GetDataByName(this.table.getdataListParm).then(response => {
  1040. console.log('table数据', response.data.list)
  1041. if (response.data.list !== null) {
  1042. for (let i = 0; i < response.data.list.length; i++) {
  1043. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1044. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1045. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1046. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1047. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1048. }
  1049. this.table.list = response.data.list
  1050. this.table.pageNum = response.data.pageNum
  1051. this.table.pageSize = response.data.pageSize
  1052. this.table.total = response.data.total
  1053. } else {
  1054. this.table.list = []
  1055. this.isDetail = false
  1056. }
  1057. setTimeout(() => {
  1058. this.table.listLoading = false
  1059. }, 100)
  1060. })
  1061. },
  1062. getList3() {
  1063. this.table.listLoading = true
  1064. GetDataByName(this.table.getdataListParm).then(response => {
  1065. console.log('table数据', response.data.list)
  1066. if (response.data.list !== null) {
  1067. for (let i = 0; i < response.data.list.length; i++) {
  1068. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1069. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1070. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1071. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1072. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1073. }
  1074. this.table.list = response.data.list
  1075. this.table.pageNum = response.data.pageNum
  1076. this.table.pageSize = response.data.pageSize
  1077. this.table.total = response.data.total
  1078. } else {
  1079. this.table.list = []
  1080. this.isDetail = false
  1081. }
  1082. setTimeout(() => {
  1083. this.table.listLoading = false
  1084. }, 100)
  1085. })
  1086. },
  1087. handleSearch() {
  1088. console.log('点击了查询')
  1089. this.table.getdataListParm.offset = 1
  1090. this.getList()
  1091. this.table.getdataListParm.parammaps.all = ''
  1092. var obj = {}
  1093. obj.tname = this.table.getdataListParm.parammaps.tname
  1094. obj.remark = this.table.getdataListParm.parammaps.remark
  1095. obj.source = this.table.getdataListParm.parammaps.source
  1096. Object.getOwnPropertyNames(obj).forEach((key) => {
  1097. console.log(key, obj[key])
  1098. if (obj[key] !== '') {
  1099. this.table.getdataListParm.parammaps.all += obj[key] + '/'
  1100. }
  1101. })
  1102. if (this.table.getdataListParm.parammaps.all.charAt(this.table.getdataListParm.parammaps.all.length - 1) == '/') {
  1103. this.table.getdataListParm.parammaps.all = this.table.getdataListParm.parammaps.all.slice(0, this.table.getdataListParm.parammaps.all.length - 1)
  1104. }
  1105. this.arrowDown = true
  1106. this.arrowUp = false
  1107. },
  1108. handleRefresh() {
  1109. console.log('点击了重置')
  1110. this.table.getdataListParm.offset = 1
  1111. this.table.getdataListParm.parammaps.ccid = ''
  1112. this.table.getdataListParm.parammaps.ccname = ''
  1113. this.table.getdataListParm.parammaps.fttype = ''
  1114. this.table.getdataListParm.parammaps.tname = ''
  1115. this.table.getdataListParm.parammaps.remark = ''
  1116. this.table.getdataListParm.parammaps.enable = ''
  1117. this.table.getdataListParm.parammaps.source = ''
  1118. this.table.getdataListParm.parammaps.all = ''
  1119. this.getList()
  1120. },
  1121. // 模板新增
  1122. handleCreate() {
  1123. console.log('点击了新增')
  1124. // 编辑true/不可编辑false
  1125. // 新增操true,编辑false,编辑保存false
  1126. for (let i = 0; i < this.table.list.length; i++) {
  1127. if (this.table.list[i].Edit === true) {
  1128. console.log(123)
  1129. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1130. return false
  1131. }
  1132. }
  1133. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', tcode: '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  1134. console.log(this.table.list)
  1135. },
  1136. // 畜生类别
  1137. changeLivestockType(item) {
  1138. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1139. },
  1140. // 配方类型
  1141. changeFormulaType(item) {
  1142. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  1143. },
  1144. createData(row) {
  1145. console.log('点击了新增保存', row)
  1146. this.table.temp.tname = row.tname
  1147. this.table.temp.tcode = row.tcode
  1148. this.table.temp.tcolor = row.tcolor
  1149. this.table.temp.ccid = row.ccid
  1150. this.table.temp.ccname = this.table.temp.ccname
  1151. this.table.temp.fttype = this.table.temp.fttype
  1152. this.table.temp.fttypeid = row.fttypeid
  1153. this.table.temp.source = row.source
  1154. this.table.temp.remark = row.remark
  1155. this.table.temp.enable = row.enable
  1156. this.table.temp.pastureid = Cookies.get('pastureid')
  1157. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1158. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1159. return false
  1160. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1161. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1162. return false
  1163. } else if (this.table.temp.tname == '') {
  1164. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1165. return false
  1166. } else if (this.table.temp.ccid == '') {
  1167. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1168. return false
  1169. } else if (this.table.temp.fttypeid == '') {
  1170. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1171. return false
  1172. }
  1173. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1174. // if (pattern.test(this.table.temp.tname)) {
  1175. // this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1176. // return false
  1177. // }
  1178. if (pattern.test(this.table.temp.tcode)) {
  1179. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1180. return false
  1181. }
  1182. console.log(this.table.temp)
  1183. this.isokDisable = true
  1184. setTimeout(() => {
  1185. this.isokDisable = false
  1186. }, 1000)
  1187. this.requestParam.name = 'insertFT'
  1188. this.requestParam.parammaps = this.table.temp
  1189. PostDataByName(this.requestParam).then(response => {
  1190. console.log('新增保存发送参数', this.requestParam)
  1191. if (response.msg !== 'fail') {
  1192. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1193. this.getList()
  1194. } else {
  1195. const isRepeat = new RegExp('Duplicate entry :feedtemplet.tCode')
  1196. if (isRepeat.test(response.data)) {
  1197. this.$message({ type: 'error', message: '配方编码不可重复,请重新录入', duration: 2000 })
  1198. } else {
  1199. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1200. }
  1201. const isRepeat2 = new RegExp('Error 1366: Incorrect integer value')
  1202. if (isRepeat2.test(response.data)) {
  1203. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1204. } else {
  1205. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1206. }
  1207. }
  1208. })
  1209. },
  1210. createCancel(row) {
  1211. console.log('点击了新增取消')
  1212. for (let i = 0; i < this.table.list.length; i++) {
  1213. if (row.myId === this.table.list[i].myId) {
  1214. var listIndex = this.table.list.indexOf(this.table.list[i])
  1215. }
  1216. if (listIndex > -1) {
  1217. this.table.list.splice(listIndex, 1)
  1218. return
  1219. }
  1220. }
  1221. },
  1222. // 模板编辑
  1223. handleUpdate(row) {
  1224. for (let i = 0; i < this.table.list.length; i++) {
  1225. if (this.table.list[i].Edit == true) {
  1226. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1227. return false
  1228. }
  1229. }
  1230. // 编辑true,不可编辑false
  1231. row.Edit = true
  1232. row.NoEdit = false
  1233. // 新增false,编辑false,编辑保存true
  1234. row.isCreate = false
  1235. row.isUpdate = false
  1236. row.isUpdateSave = true
  1237. if (row.ccname !== undefined) {
  1238. row.ccid = String(row.ccid)
  1239. }
  1240. this.table.temp.ccname = row.ccname
  1241. row.fttypeid = String(row.fttypeid)
  1242. this.table.temp.fttype = row.fttype
  1243. },
  1244. updateData(row) {
  1245. console.log('点击了编辑保存', row)
  1246. this.table.temp.tname = row.tname
  1247. this.table.temp.tcode = row.tcode
  1248. this.table.temp.tcolor = row.tcolor
  1249. this.table.temp.ccid = row.ccid
  1250. this.table.temp.fttypeid = row.fttypeid
  1251. this.table.temp.source = row.source
  1252. this.table.temp.remark = row.remark
  1253. this.table.temp.enable = row.enable
  1254. this.table.temp.ccname = this.table.temp.ccname
  1255. this.table.temp.fttype = this.table.temp.fttype
  1256. this.table.temp.pastureid = row.pastureid
  1257. this.table.temp.id = row.id
  1258. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1259. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1260. return false
  1261. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1262. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1263. return false
  1264. } else if (this.table.temp.tname == '') {
  1265. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1266. return false
  1267. } else if (this.table.temp.ccid == '') {
  1268. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1269. return false
  1270. } else if (this.table.temp.fttypeid == '') {
  1271. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1272. return false
  1273. }
  1274. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1275. // if (pattern.test(this.table.temp.tname)) {
  1276. // this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1277. // return false
  1278. // }
  1279. if (pattern.test(this.table.temp.tcode)) {
  1280. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1281. return false
  1282. }
  1283. console.log(this.table.temp)
  1284. this.isokDisable = true
  1285. setTimeout(() => {
  1286. this.isokDisable = false
  1287. }, 1000)
  1288. this.requestParam.name = 'updateFT'
  1289. this.requestParam.parammaps = this.table.temp
  1290. PostDataByName(this.requestParam).then(response => {
  1291. console.log('新增保存发送参数', this.requestParam)
  1292. if (response.msg !== 'fail') {
  1293. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1294. this.getList()
  1295. } else {
  1296. const isRepeat = new RegExp('Duplicate entry :feedtemplet.tCode')
  1297. if (isRepeat.test(response.data)) {
  1298. this.$message({ type: 'error', message: '配方编码不可重复,请重新录入', duration: 2000 })
  1299. } else {
  1300. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1301. }
  1302. ss
  1303. }
  1304. })
  1305. },
  1306. updateCancel(row) {
  1307. console.log('点击了编辑取消')
  1308. // 编辑false,不可编辑true
  1309. row.Edit = false
  1310. row.NoEdit = true
  1311. // 新增false,编辑true,编辑保存false
  1312. row.isCreate = false
  1313. row.isUpdate = true
  1314. row.isUpdateSave = false
  1315. this.getList()
  1316. },
  1317. // 删除
  1318. handleRowDelete(row) {
  1319. console.log('点击了行内删除')
  1320. MessageBox.confirm('是否确认删除此信息?', {
  1321. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1322. }).then(() => {
  1323. this.requestParam.common = { 'returnmap': '0' }
  1324. this.requestParam.data = []
  1325. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1326. pastureid: row.pastureid,
  1327. id: row.id
  1328. }}
  1329. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1330. pastureid: row.pastureid,
  1331. id: row.id
  1332. }}
  1333. ExecDataByConfig(this.requestParam).then(response => {
  1334. console.log('新增保存发送参数', this.requestParam)
  1335. if (response.msg === 'fail') {
  1336. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1337. } else {
  1338. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1339. this.getList()
  1340. this.isDetail = false
  1341. }
  1342. })
  1343. }).catch(() => {
  1344. this.$message({ type: 'info', message: '已取消删除' })
  1345. })
  1346. },
  1347. handleSelectionChange(val) {
  1348. console.log('勾选数据', val)
  1349. this.selectList = val
  1350. },
  1351. handleDelete() {
  1352. console.log('点击了删除')
  1353. if (this.selectList.length == 0) {
  1354. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1355. } else {
  1356. MessageBox.confirm('是否确认删除此信息?', {
  1357. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1358. }).then(() => {
  1359. console.log(this.selectList)
  1360. this.requestParam.common = { 'returnmap': '0' }
  1361. this.requestParam.data = []
  1362. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1363. this.requestParam.data[0].children = []
  1364. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1365. id: '@insertSpotList.id',
  1366. pastureid: '@insertSpotList.pastureid'
  1367. }}
  1368. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1369. id: '@insertSpotList.id',
  1370. pastureid: '@insertSpotList.pastureid'
  1371. }}
  1372. ExecDataByConfig(this.requestParam).then(response => {
  1373. console.log('删除保存发送参数', this.requestParam)
  1374. if (response.msg === 'fail') {
  1375. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1376. } else {
  1377. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1378. this.getList()
  1379. }
  1380. })
  1381. })
  1382. }
  1383. },
  1384. // 复制
  1385. handleCopy() {
  1386. if (this.selectList.length == 0) {
  1387. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1388. } else {
  1389. MessageBox.confirm('是否确认复制此信息?', {
  1390. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1391. }).then(() => {
  1392. console.log(this.selectList)
  1393. this.requestParam.common = { 'returnmap': '0' }
  1394. this.requestParam.data = []
  1395. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1396. this.requestParam.data[0].children = []
  1397. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1398. ftid: '@insertSpotList.id',
  1399. pastureid: '@insertSpotList.pastureid'
  1400. }}
  1401. ExecDataByConfig(this.requestParam).then(response => {
  1402. console.log('复制保存发送参数', this.requestParam)
  1403. if (response.msg === 'fail') {
  1404. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1405. } else {
  1406. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1407. this.getList()
  1408. }
  1409. })
  1410. })
  1411. }
  1412. },
  1413. // 配方记录
  1414. handleRecipeRecord() {
  1415. console.log('点击了配方记录')
  1416. this.template.dialogStatus = 'RecipeRecord'
  1417. this.dialogFull = false
  1418. this.template.dialogFormVisible = true
  1419. this.template.table.getdataListParm.parammaps.ccname = ''
  1420. this.template.table.getdataListParm.parammaps.fttype = ''
  1421. this.template.table.getdataListParm.parammaps.enable = ''
  1422. this.template.table.getdataListParm.parammaps.tname = ''
  1423. this.template.table.getdataListParm.parammaps.remark = ''
  1424. this.template.table.getdataListParm.parammaps.source = ''
  1425. this.template.table.getdataListParm.offset = 1
  1426. this.getDateList()
  1427. this.isDetailDialog = false
  1428. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  1429. },
  1430. // 历史时间
  1431. getDateList() {
  1432. GetDataByName(this.template.getdataDateParm).then(response => {
  1433. console.log('table数据', response.data.list)
  1434. if (response.data.list !== null) {
  1435. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1436. this.getTemplateDialogList()
  1437. } else {
  1438. this.template.table.getdataListParm.parammaps.date = ''
  1439. }
  1440. })
  1441. },
  1442. // 配方记录-模板
  1443. getTemplateDialogList() {
  1444. this.template.table.listLoading = true
  1445. GetDataByName(this.template.table.getdataListParm).then(response => {
  1446. console.log('table数据', response.data.list)
  1447. if (response.data.list !== null) {
  1448. this.template.table.list = response.data.list
  1449. this.template.table.pageNum = response.data.pageNum
  1450. this.template.table.pageSize = response.data.pageSize
  1451. this.template.table.total = response.data.total
  1452. } else {
  1453. this.template.table.list = []
  1454. this.template.table2.list = []
  1455. }
  1456. setTimeout(() => {
  1457. this.template.table.listLoading = false
  1458. }, 100)
  1459. })
  1460. },
  1461. handleDialogSearch() {
  1462. this.template.table.getdataListParm.offset = 1
  1463. this.getTemplateDialogList()
  1464. this.arrowDown = true
  1465. this.arrowUp = false
  1466. },
  1467. handleDialogRefresh() {
  1468. this.template.table.getdataListParm.parammaps.ccname = ''
  1469. this.template.table.getdataListParm.parammaps.fttype = ''
  1470. this.template.table.getdataListParm.parammaps.enable = ''
  1471. this.template.table.getdataListParm.parammaps.tname = ''
  1472. this.template.table.getdataListParm.parammaps.remark = ''
  1473. this.template.table.getdataListParm.parammaps.source = ''
  1474. this.template.table.getdataListParm.offset = 1
  1475. this.getTemplateDialogList()
  1476. },
  1477. // 配方记录-模板行点击
  1478. tableRowClickDialog(row, column, event) {
  1479. console.log('配方记录-模板行点击')
  1480. this.isDetailDialog = true
  1481. this.template.table2.getdataListParm.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1482. this.template.table2.getdataListParm.parammaps.version = row.version
  1483. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1484. this.template.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1485. this.myheight2 = document.documentElement.clientHeight - 85 - 265 - 185
  1486. this.getDialogList()
  1487. this.getDownList()
  1488. // aiaiaiai
  1489. },
  1490. getDialogList() {
  1491. this.template.table2.listLoading = true
  1492. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1493. console.log('table数据', response.data.list)
  1494. if (response.data.list !== null) {
  1495. this.template.table2.list = response.data.list
  1496. this.template.table2.pageNum = response.data.pageNum
  1497. this.template.table2.pageSize = response.data.pageSize
  1498. this.template.table2.total = response.data.total
  1499. } else {
  1500. this.template.table2.list = []
  1501. }
  1502. this.$nextTick(function() {
  1503. document.querySelector('#detailDialog2').scrollIntoView()
  1504. // window.scrollTo({
  1505. // 'top': this.$refs.detailDialog2.clientHeight
  1506. // })
  1507. })
  1508. setTimeout(() => {
  1509. this.template.table2.listLoading = false
  1510. }, 100)
  1511. })
  1512. },
  1513. handleDialogSearch2() {
  1514. console.log('点击了查询')
  1515. this.arrowDown2 = true
  1516. this.arrowUp2 = false
  1517. this.template.table2.getdataListParm.offset = 1
  1518. this.getDialogList2()
  1519. },
  1520. handleDialogRefresh2() {
  1521. console.log('点击了重置')
  1522. this.template.table2.getdataListParm.parammaps.fname = ''
  1523. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1524. this.template.table2.getdataListParm.parammaps.fweight = ''
  1525. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1526. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1527. this.template.table2.getdataListParm.parammaps.sort = ''
  1528. this.template.table2.getdataListParm.offset = 1
  1529. this.getDialogList2()
  1530. },
  1531. getDialogList2() {
  1532. this.template.table2.listLoading = true
  1533. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1534. console.log('table数据', response.data.list)
  1535. if (response.data.list !== null) {
  1536. this.template.table2.list = response.data.list
  1537. this.template.table2.pageNum = response.data.pageNum
  1538. this.template.table2.pageSize = response.data.pageSize
  1539. this.template.table2.total = response.data.total
  1540. } else {
  1541. this.template.table2.list = []
  1542. }
  1543. this.$nextTick(function() {
  1544. window.scrollTo({
  1545. 'top': this.$refs.templateDialog.clientHeight
  1546. })
  1547. })
  1548. setTimeout(() => {
  1549. this.template.table2.listLoading = false
  1550. }, 100)
  1551. })
  1552. },
  1553. // 导出
  1554. handleExport(item) {
  1555. if (item == 1) {
  1556. console.log('点击了导出模板')
  1557. const requestParam = this.requestParam
  1558. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/配方计划/配方模板导入模板.xlsx' // 请求下载文件的地址
  1559. console.log(url)
  1560. axios({
  1561. method: 'GET',
  1562. url: url,
  1563. data: requestParam,
  1564. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1565. responseType: 'blob'
  1566. }).then(res => {
  1567. if (!res) return
  1568. this.percentage = 99
  1569. setTimeout(() => {
  1570. this.isPercentage = false
  1571. }, 2000)
  1572. const blob = new Blob([res.data], {
  1573. type: 'application/octet-stream;charset=utf-8'
  1574. })
  1575. const url = window.URL.createObjectURL(blob)
  1576. const aLink = document.createElement('a')
  1577. aLink.style.display = 'none'
  1578. aLink.href = url
  1579. const docname = '配方模板导入模板.xlsx'
  1580. aLink.setAttribute('download', docname) // 下载的文件
  1581. document.body.appendChild(aLink)
  1582. aLink.click()
  1583. document.body.removeChild(aLink)
  1584. window.URL.revokeObjectURL(url)
  1585. })
  1586. } else {
  1587. console.log('点击了导出数据')
  1588. this.download.getdataListParm.name = 'downloadFTList'
  1589. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1590. GetDataByName(this.download.getdataListParm).then(response => {
  1591. if (response.data.list !== null) {
  1592. for (let i = 0; i < response.data.list.length; i++) {
  1593. if (response.data.list[i].islockcount == 0) {
  1594. this.$set(response.data.list[i], 'islockcount', '否')
  1595. } else {
  1596. this.$set(response.data.list[i], 'islockcount', '是')
  1597. }
  1598. if (response.data.list[i].enable == 0) {
  1599. this.$set(response.data.list[i], 'enable', '否')
  1600. } else {
  1601. this.$set(response.data.list[i], 'enable', '是')
  1602. }
  1603. }
  1604. this.download.list = response.data.list
  1605. } else {
  1606. this.download.list = []
  1607. }
  1608. var excelDatas = [
  1609. {
  1610. tHeader: ['配方名称', '配方编码', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1611. filterVal: ['tname', 'tcode', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1612. tableDatas: this.download.list,
  1613. sheetName: 'Sheet1'
  1614. }
  1615. ]
  1616. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1617. })
  1618. }
  1619. },
  1620. beforeImport(file) {
  1621. const isLt2M = file.size / 1024 / 1024 < 2
  1622. if (!isLt2M) {
  1623. this.$message.error('上传文件大小不能超过 2MB!')
  1624. }
  1625. return isLt2M
  1626. },
  1627. handleImportSuccess(res, file) {
  1628. this.getList()
  1629. if (res.msg === 'ok') {
  1630. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1631. if (res.data.err_count > 0) {
  1632. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1633. import('@/vendor/Export2Excel').then(excel => {
  1634. const list1 = res.data.result
  1635. const tHeader = [
  1636. '配方名称', '牲畜类别', '配方类型', '备注', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1637. ]
  1638. const filterVal = [
  1639. '配方名称', '牲畜类别', '配方类型', '备注', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1640. ]
  1641. const data1 = this.formatJson(filterVal, list1)
  1642. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1643. })
  1644. }
  1645. } else {
  1646. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1647. }
  1648. },
  1649. formatJson(filterVal, jsonData) {
  1650. return jsonData.map(v =>
  1651. filterVal.map(j => {
  1652. if (j === 'timestamp') {
  1653. return parseTime(v[j])
  1654. } else {
  1655. return v[j]
  1656. }
  1657. })
  1658. )
  1659. },
  1660. changeDate() {
  1661. this.getTemplateDialogList()
  1662. },
  1663. // 应用
  1664. handleApplication() {
  1665. console.log('点击了应用')
  1666. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1667. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1668. }).then(() => {
  1669. this.requestParam.name = 'applyFTdate'
  1670. this.requestParam.parammaps = {}
  1671. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1672. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1673. PostDataByName(this.requestParam).then(response => {
  1674. if (response.msg === 'fail') {
  1675. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1676. } else {
  1677. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1678. this.getTemplateDialogList()
  1679. this.getList()
  1680. }
  1681. })
  1682. }).catch(() => {
  1683. this.$message({ type: 'info', message: '已取消应用' })
  1684. })
  1685. },
  1686. // 模板行点击
  1687. tableRowClick(row, column, event) {
  1688. console.log(row, column, event)
  1689. for (let i = 0; i < this.table.list.length; i++) {
  1690. if (this.table.list[i].Edit == true) {
  1691. return false
  1692. }
  1693. }
  1694. console.log(this.isOrder)
  1695. if (this.isOrder == false) {
  1696. this.$message({ type: 'error', message: '请保存或取消当前更改顺序操作', duration: 2000 })
  1697. } else {
  1698. if (column.label !== '操作') {
  1699. this.isDetail = true // 点击行显示详情
  1700. this.table2.getdataListParm.parammaps.ftid = row.id
  1701. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1702. this.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1703. if (row.fttype == '预混配方') {
  1704. this.requestParams[2].parammaps.type = '1'
  1705. } else {
  1706. this.requestParams[2].parammaps.type = ''
  1707. }
  1708. this.myheight = document.documentElement.clientHeight - 85 - 265 - 185
  1709. this.getList2()
  1710. this.getDownList()
  1711. }
  1712. }
  1713. },
  1714. handleCloseTable2() {
  1715. this.isDetail = false
  1716. this.myheight = ''
  1717. },
  1718. handleDialogCloseTable2() {
  1719. this.isDetailDialog = false
  1720. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  1721. },
  1722. // -------------------详情-----------------------------
  1723. // 获取是否显示是否锁定牛头数
  1724. getIsLockCount() {
  1725. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1726. console.log(response.data.list)
  1727. if (response.data.list[0].inforvalue == 0) {
  1728. this.lockCount.isLockCount = false
  1729. } else {
  1730. this.lockCount.isLockCount = true
  1731. }
  1732. })
  1733. },
  1734. // 详情
  1735. getList2() {
  1736. this.table2.listLoading = true
  1737. GetDataByName(this.table2.getdataListParm).then(response => {
  1738. console.log('table数据', response.data.list)
  1739. if (response.data.list !== null) {
  1740. for (let i = 0; i < response.data.list.length; i++) {
  1741. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1742. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1743. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1744. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1745. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1746. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1747. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1748. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1749. console.log(this.table2.getdataListParm.parammaps)
  1750. console.log(this.table2, '===')
  1751. }
  1752. this.table2.getDryweightParm.parammaps = this.table2.getdataListParm.parammaps
  1753. this.getDryWeight()
  1754. // for (let i = 0; i < response.data.list.length; i++) {
  1755. // console.log(response.data.list[i].fweight, '===12333')
  1756. // }
  1757. this.table2.list = response.data.list
  1758. this.table2.pageNum = response.data.pageNum
  1759. this.table2.pageSize = response.data.pageSize
  1760. this.table2.total = response.data.total
  1761. } else {
  1762. this.table2.list = []
  1763. }
  1764. setTimeout(() => {
  1765. this.table2.listLoading = false
  1766. }, 100)
  1767. })
  1768. },
  1769. // 行拖拽
  1770. rowDrop() {
  1771. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1772. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1773. // this.sorTable()
  1774. const that = this
  1775. // Sortable.create(tbody, {
  1776. var sortable = Sortable.create(tbody, {
  1777. disabled: that.dropState,
  1778. onChoose({ newIndex, oldIndex }) {
  1779. console.log(that.isOrder, 'that.isOrder == false')
  1780. console.log(that.dropState, 'that.dropState')
  1781. if (that.dropState == true || that.isOrder == true) {
  1782. sortable.destroy()
  1783. }
  1784. },
  1785. onEnd({ newIndex, oldIndex }) {
  1786. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1787. that.table2.list.splice(newIndex, 0, currRow)
  1788. console.log('索引', newIndex)
  1789. console.log('拖动数据', currRow)
  1790. console.log('上', that.table2.list[newIndex - 1])
  1791. console.log('下', that.table2.list[newIndex + 1])
  1792. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1793. for (let i = 0; i < that.table2.list.length; i++) {
  1794. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1795. }
  1796. currRow.sort = 0
  1797. currRow.feedgroup = currRow.fname
  1798. console.log('拖动至最上方无值')
  1799. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1800. currRow.sort = that.table2.list[newIndex - 1].sort
  1801. console.log('拖动值顺序等于上值顺序')
  1802. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1803. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1804. currRow.feedgroup = currRow.fname
  1805. console.log('拖动至最下方无值')
  1806. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1807. currRow.sort == that.table2.list[newIndex + 1].sort
  1808. console.log('拖动值顺序等于下值顺序')
  1809. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1810. currRow.sort = that.table2.list[newIndex - 1].sort
  1811. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1812. console.log('拖动至上下顺序一致')
  1813. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1814. console.log('上下')
  1815. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1816. console.log(newIndex)
  1817. for (let i = newIndex; i < that.table2.list.length; i++) {
  1818. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1819. }
  1820. }
  1821. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1822. currRow.feedgroup = currRow.fname
  1823. console.log(that.table2.list[newIndex + 1].sort)
  1824. }
  1825. }
  1826. })
  1827. console.log(sortable.option('disabled'))
  1828. },
  1829. handleChangeOrder() {
  1830. this.isOrder = false
  1831. this.rowDrop()
  1832. },
  1833. saveChangeOrder() {
  1834. // 保存顺序
  1835. console.log(this.table2.list)
  1836. this.requestParam = {}
  1837. this.requestParam.common = { 'returnmap': '0' }
  1838. this.requestParam.data = []
  1839. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table2.list }}
  1840. this.requestParam.data[0].children = []
  1841. this.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1842. id: '@insertSpotList.id',
  1843. pastureid: '@insertSpotList.pastureid',
  1844. sort: '@insertSpotList.sort',
  1845. feedgroup: '@insertSpotList.feedgroup'
  1846. }}
  1847. ExecDataByConfig(this.requestParam).then(response => {
  1848. console.log('顺序切换保存发送参数', this.requestParam)
  1849. if (response.msg === 'fail') {
  1850. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1851. } else {
  1852. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1853. this.getList2()
  1854. this.getList3()
  1855. this.isOrder = true
  1856. }
  1857. })
  1858. },
  1859. cancelChangeOrder() {
  1860. // 取消顺序
  1861. this.getList2()
  1862. this.isOrder = true
  1863. },
  1864. handleSearch2() {
  1865. console.log('点击了查询')
  1866. this.arrowDown2 = true
  1867. this.arrowUp2 = false
  1868. this.table2.getdataListParm.offset = 1
  1869. // fname, feedgroup, fweight, autosecondname, islockcount, sort
  1870. // this.table2.getdataListParm.parammaps.all = this.table2.getdataListParm.parammaps.fname + ' ' + this.table2.getdataListParm.parammaps.feedgroup + ' ' + this.table2.getdataListParm.parammaps.fweight + ' ' + this.table2.getdataListParm.parammaps.autosecondname + ' ' + this.table2.getdataListParm.parammaps.islockcount + ' ' + this.table2.getdataListParm.parammaps.sort
  1871. this.table2.getdataListParm.parammaps.all = ''
  1872. var obj = {}
  1873. obj.fname = this.table2.getdataListParm.parammaps.fname
  1874. obj.feedgroup = this.table2.getdataListParm.parammaps.feedgroup
  1875. obj.fweight = this.table2.getdataListParm.parammaps.fweight
  1876. obj.autosecondname = this.table2.getdataListParm.parammaps.autosecondname
  1877. if (this.table2.getdataListParm.parammaps.islockcount !== '') {
  1878. if (this.table2.getdataListParm.parammaps.islockcount == 0) {
  1879. this.table2.getdataListParm.parammaps.islockcount = '否'
  1880. } else {
  1881. this.table2.getdataListParm.parammaps.islockcount = '是'
  1882. }
  1883. }
  1884. obj.islockcount = this.table2.getdataListParm.parammaps.islockcount
  1885. obj.sort = this.table2.getdataListParm.parammaps.sort
  1886. Object.getOwnPropertyNames(obj).forEach((key) => {
  1887. console.log(key, obj[key])
  1888. if (obj[key] !== '') {
  1889. this.table2.getdataListParm.parammaps.all += obj[key] + '/'
  1890. }
  1891. })
  1892. if (this.table2.getdataListParm.parammaps.all.charAt(this.table2.getdataListParm.parammaps.all.length - 1) == '/') {
  1893. this.table2.getdataListParm.parammaps.all = this.table2.getdataListParm.parammaps.all.slice(0, this.table2.getdataListParm.parammaps.all.length - 1)
  1894. }
  1895. this.getList2()
  1896. },
  1897. handleRefresh2() {
  1898. console.log('点击了重置')
  1899. this.table2.getdataListParm.parammaps.fname = ''
  1900. this.table2.getdataListParm.parammaps.feedgroup = ''
  1901. this.table2.getdataListParm.parammaps.fweight = ''
  1902. this.table2.getdataListParm.parammaps.autosecondname = ''
  1903. this.table2.getdataListParm.parammaps.islockcount = '0'
  1904. this.table2.getdataListParm.parammaps.sort = ''
  1905. this.table2.getdataListParm.parammaps.all = ''
  1906. this.table2.getdataListParm.offset = 1
  1907. this.getList2()
  1908. },
  1909. // 详情新增
  1910. handleCreate2() {
  1911. console.log('点击了详情新增', this.table2.list)
  1912. // 编辑true/不可编辑false
  1913. // 新增操true,编辑false,编辑保存false
  1914. console.log(11)
  1915. for (let i = 0; i < this.table2.list.length; i++) {
  1916. if (this.table2.list[i].Edit === true) {
  1917. console.log(123)
  1918. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1919. return false
  1920. }
  1921. }
  1922. console.log(this.table2.list)
  1923. if (this.table2.list.length == 0) {
  1924. var mysort = 0
  1925. } else {
  1926. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1927. }
  1928. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1929. console.log(this.table2.list)
  1930. },
  1931. changeFname(item, row) {
  1932. console.log(item, row)
  1933. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1934. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1935. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1936. this.table2.temp.preftid = '0'
  1937. } else {
  1938. this.table2.temp.preftid = item
  1939. }
  1940. if (row.sort == '') {
  1941. row.feedgroup = this.table2.temp.fname
  1942. } else {
  1943. if (row.isCreate == true) { // 新增状态下
  1944. for (let i = 1; i < this.table2.list.length; i++) {
  1945. if (this.table2.list[i].sort == row.sort) {
  1946. console.log(this.table2.list[i])
  1947. row.feedgroup = this.table2.list[i].feedgroup
  1948. break
  1949. } else {
  1950. row.feedgroup = this.table2.temp.fname
  1951. }
  1952. }
  1953. } else if (row.isUpdateSave == true) { // 编辑状态下
  1954. var Arr = []
  1955. for (let i = 0; i < this.table2.list.length; i++) {
  1956. Arr.push(this.table2.list[i].sort)
  1957. }
  1958. var Count = 0
  1959. for (let i = 0; i < Arr.length; i++) {
  1960. if (Arr[i] == row.sort) {
  1961. Count++
  1962. }
  1963. }
  1964. for (let i = 0; i < this.table2.list.length; i++) {
  1965. if (Count > 1) {
  1966. row.feedgroup = this.table2.list[i].feedgroup
  1967. console.log(this.table2.list[i].feedgroup)
  1968. break
  1969. } else if (Count == 1) {
  1970. row.feedgroup = this.table2.temp.fname
  1971. console.log(222, this.table2.temp.fname)
  1972. }
  1973. }
  1974. }
  1975. }
  1976. },
  1977. bort(row) {
  1978. if (row.isCreate == true) {
  1979. if (row.sort !== '') {
  1980. for (let i = 1; i < this.table2.list.length; i++) {
  1981. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1982. row.feedgroup = this.table2.list[i].feedgroup
  1983. return false
  1984. } else {
  1985. row.feedgroup = row.fname
  1986. }
  1987. }
  1988. } else {
  1989. row.feedgroup = row.fname
  1990. }
  1991. } else if (row.isUpdateSave == true) {
  1992. if (row.sort !== '') {
  1993. for (let i = 0; i < this.table2.list.length; i++) {
  1994. if (this.table2.list[i].sort == row.sort) {
  1995. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1996. if (this.table2.list[i].id !== row.id) {
  1997. row.isGroupDisabled = true
  1998. row.feedgroup = this.table2.list[i].feedgroup
  1999. break
  2000. }
  2001. } else {
  2002. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  2003. row.isGroupDisabled = true
  2004. row.feedgroup = row.fname
  2005. }
  2006. }
  2007. } else {
  2008. row.feedgroup = row.fname
  2009. }
  2010. }
  2011. },
  2012. createData2(row) {
  2013. console.log('点击了详情新增保存1', row)
  2014. this.table2.temp.pastureid = Cookies.get('pastureid')
  2015. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  2016. this.table2.temp.fid = row.fid
  2017. this.table2.temp.fname = this.table2.temp.fname
  2018. this.table2.temp.fweight = row.fweight
  2019. this.table2.temp.islockcount = row.islockcount
  2020. this.table2.temp.sort = row.sort
  2021. this.table2.temp.feedgroup = row.feedgroup
  2022. this.table2.temp.preftid = this.table2.temp.preftid
  2023. this.table2.temp.autosecond = row.autosecond
  2024. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2025. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  2026. return false
  2027. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2028. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  2029. return false
  2030. } else if (this.table2.temp.fid == '') {
  2031. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2032. return false
  2033. } else if (this.table2.temp.fweight == '') {
  2034. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2035. return false
  2036. } else if (this.table2.temp.autosecond == '') {
  2037. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2038. return false
  2039. }
  2040. if (this.table2.temp.sort !== '') {
  2041. this.table2.temp.sort = this.table2.temp.sort
  2042. } else {
  2043. console.log(this.table2.list.length)
  2044. if (this.table2.list.length == 1) {
  2045. this.table2.temp.sort = 0
  2046. } else {
  2047. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2048. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2049. }
  2050. }
  2051. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2052. if (parseInt(this.table2.temp.preftid) > 0) {
  2053. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2054. return false
  2055. }
  2056. }
  2057. // 校验顺序是否>=0
  2058. var ruleSort = /^\d+$/
  2059. if (!ruleSort.test(this.table2.temp.sort)) {
  2060. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2061. return false
  2062. }
  2063. // 检验重量>0
  2064. this.table2.temp.fweight = formatNum(this.table2.temp.fweight, parseInt(Cookies.get('decimal'))) // 根据默认参数设置小数位数
  2065. row.fweight = formatNum(row.fweight, parseInt(Cookies.get('decimal')))
  2066. // var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2067. if (this.table2.temp.fweight == 0) {
  2068. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  2069. return false
  2070. }
  2071. this.isokDisable = true
  2072. setTimeout(() => {
  2073. this.isokDisable = false
  2074. }, 1000)
  2075. this.requestParam.common = { 'returnmap': '0' }
  2076. this.requestParam.data = []
  2077. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2078. pastureid: this.table2.temp.pastureid,
  2079. ftid: this.table2.getdataListParm.parammaps.ftid,
  2080. fid: row.fid,
  2081. fname: this.table2.temp.fname,
  2082. fweight: String(row.fweight),
  2083. islockcount: row.islockcount,
  2084. sort: row.sort,
  2085. feedgroup: row.feedgroup,
  2086. preftid: this.table2.temp.preftid,
  2087. autosecond: row.autosecond
  2088. }}
  2089. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2090. pastureid: this.table2.temp.pastureid,
  2091. ftid: this.table2.getdataListParm.parammaps.ftid,
  2092. type: this.table2.getdataListParm.parammaps.fttypeid
  2093. }}
  2094. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2095. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2096. id: this.table2.getdataListParm.parammaps.ftid
  2097. }}
  2098. ExecDataByConfig(this.requestParam).then(response => {
  2099. console.log('新增保存发送参数', this.requestParam)
  2100. if (response.msg !== 'fail') {
  2101. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2102. this.getList2()
  2103. this.getList3()
  2104. } else {
  2105. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2106. }
  2107. })
  2108. },
  2109. createCancel2(row) {
  2110. console.log('点击了详情新增取消')
  2111. for (let i = 0; i < this.table2.list.length; i++) {
  2112. if (row.myId === this.table2.list[i].myId) {
  2113. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  2114. }
  2115. if (listIndex > -1) {
  2116. this.table2.list.splice(listIndex, 1)
  2117. return
  2118. }
  2119. }
  2120. this.getDialogList()
  2121. },
  2122. // 详情编辑
  2123. handleUpdate2(row) {
  2124. console.log('详情编辑', row)
  2125. this.dropState = true
  2126. row.isGroupDisabled = false
  2127. row.islockcount = String(row.islockcount)
  2128. row.fid = String(row.fid)
  2129. row.autosecond = String(row.autosecond)
  2130. this.table2.temp.fname = row.fname
  2131. this.table2.temp.preftid = row.preftid
  2132. const rowArr = []
  2133. for (let i = 0; i < this.table2.list.length; i++) {
  2134. if (this.table2.list[i].Edit == true) {
  2135. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  2136. return false
  2137. }
  2138. rowArr.push(this.table2.list[i].sort)
  2139. }
  2140. var count = 0
  2141. for (let i = 0; i < rowArr.length; i++) {
  2142. if (rowArr[i] == row.sort) {
  2143. count++
  2144. }
  2145. }
  2146. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  2147. if (count == 1) {
  2148. // 饲料组编辑false,不可编辑true
  2149. row.groupEdit = false
  2150. row.groupNoEdit = true
  2151. // 编辑true,不可编辑false
  2152. row.Edit = true
  2153. row.NoEdit = false
  2154. // 新增false,编辑false,编辑保存true
  2155. row.isCreate = false
  2156. row.isUpdate = false
  2157. row.isUpdateSave = true
  2158. } else if (count > 1) {
  2159. // 饲料组编辑true,不可编辑false
  2160. row.groupEdit = true
  2161. row.groupNoEdit = false
  2162. console.log(222)
  2163. // 编辑true,不可编辑false
  2164. row.Edit = true
  2165. row.NoEdit = false
  2166. // 新增false,编辑false,编辑保存true
  2167. row.isCreate = false
  2168. row.isUpdate = false
  2169. row.isUpdateSave = true
  2170. return false
  2171. }
  2172. },
  2173. updateData2(row) {
  2174. console.log('点击了详情编辑保存', row)
  2175. this.isokDisable = true
  2176. setTimeout(() => {
  2177. this.isokDisable = false
  2178. }, 1000)
  2179. this.table2.temp.pastureid = row.pastureid
  2180. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  2181. this.table2.temp.fid = row.fid
  2182. this.table2.temp.fname = this.table2.temp.fname
  2183. this.table2.temp.fweight = row.fweight
  2184. this.table2.temp.islockcount = row.islockcount
  2185. this.table2.temp.sort = row.sort
  2186. this.table2.temp.feedgroup = row.feedgroup
  2187. this.table2.temp.preftid = this.table2.temp.preftid
  2188. this.table2.temp.autosecond = row.autosecond
  2189. this.table2.temp.id = row.id
  2190. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2191. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  2192. return false
  2193. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2194. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  2195. return false
  2196. } else if (this.table2.temp.fid == '') {
  2197. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2198. return false
  2199. } else if (this.table2.temp.fweight == '') {
  2200. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2201. return false
  2202. } else if (this.table2.temp.autosecond == '') {
  2203. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2204. return false
  2205. }
  2206. if (this.table2.temp.sort !== '') {
  2207. this.table2.temp.sort = this.table2.temp.sort
  2208. } else {
  2209. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2210. }
  2211. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2212. if (parseInt(this.table2.temp.preftid) > 0) {
  2213. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2214. return false
  2215. }
  2216. }
  2217. // 校验顺序是否>=0
  2218. var ruleSort = /^\d+$/
  2219. if (!ruleSort.test(this.table2.temp.sort)) {
  2220. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2221. return false
  2222. }
  2223. this.table2.temp.fweight = formatNum(this.table2.temp.fweight, parseInt(Cookies.get('decimal'))) // 根据默认参数设置小数位数
  2224. row.fweight = formatNum(row.fweight, parseInt(Cookies.get('decimal')))
  2225. // 检验重量>0
  2226. // var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2227. if (this.table2.temp.fweight == 0) {
  2228. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  2229. return false
  2230. }
  2231. this.requestParam.common = { 'returnmap': '0' }
  2232. this.requestParam.data = []
  2233. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  2234. pastureid: row.pastureid,
  2235. ftid: this.table2.getdataListParm.parammaps.ftid,
  2236. fid: row.fid,
  2237. fname: this.table2.temp.fname,
  2238. fweight: String(row.fweight),
  2239. islockcount: row.islockcount,
  2240. sort: row.sort,
  2241. feedgroup: row.feedgroup,
  2242. preftid: this.table2.temp.preftid,
  2243. autosecond: row.autosecond,
  2244. id: row.id
  2245. }}
  2246. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2247. pastureid: row.pastureid,
  2248. ftid: this.table2.getdataListParm.parammaps.ftid,
  2249. type: this.table2.getdataListParm.parammaps.fttypeid
  2250. }}
  2251. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  2252. pastureid: row.pastureid,
  2253. ftid: this.table2.getdataListParm.parammaps.ftid,
  2254. sort: row.sort,
  2255. feedgroup: row.feedgroup
  2256. }}
  2257. this.requestParam.data[3] = { 'name': 'updateFTdetailGroup', 'type': 'e', 'parammaps': {
  2258. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2259. ftid: this.table2.getdataListParm.parammaps.ftid
  2260. }}
  2261. ExecDataByConfig(this.requestParam).then(response => {
  2262. console.log('新增保存发送参数', this.requestParam)
  2263. if (response.msg !== 'fail') {
  2264. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2265. this.getList2()
  2266. this.getList3()
  2267. this.dropState = false
  2268. } else {
  2269. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2270. }
  2271. })
  2272. },
  2273. updateCancel2(row) {
  2274. console.log('点击了详情编辑取消')
  2275. // 饲料组编辑false,不可编辑true
  2276. row.groupEdit = false
  2277. row.groupNoEdit = true
  2278. // 编辑false,不可编辑true
  2279. row.Edit = false
  2280. row.NoEdit = true
  2281. // 新增false,编辑true,编辑保存false
  2282. row.isCreate = false
  2283. row.isUpdate = true
  2284. row.isUpdateSave = false
  2285. this.getList2()
  2286. this.dropState = false
  2287. },
  2288. // 详情删除
  2289. handleRowDelete2(row) {
  2290. console.log('点击了行内删除')
  2291. MessageBox.confirm('是否确认删除此信息?', {
  2292. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2293. }).then(() => {
  2294. console.log(this.table2.list.length)
  2295. if (this.table2.list.length > 1) {
  2296. this.requestParam.common = { 'returnmap': '0' }
  2297. this.requestParam.data = []
  2298. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2299. pastureid: row.pastureid,
  2300. id: row.id
  2301. }}
  2302. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2303. pastureid: row.pastureid,
  2304. ftid: this.table2.getdataListParm.parammaps.ftid,
  2305. type: this.table2.getdataListParm.parammaps.fttypeid
  2306. }}
  2307. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2308. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2309. id: this.table2.getdataListParm.parammaps.ftid
  2310. }}
  2311. } else {
  2312. this.requestParam.common = { 'returnmap': '0' }
  2313. this.requestParam.data = []
  2314. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2315. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2316. id: this.table2.getdataListParm.parammaps.ftid
  2317. }}
  2318. this.requestParam.data[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2319. pastureid: row.pastureid,
  2320. id: row.id
  2321. }}
  2322. this.requestParam.data[2] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2323. pastureid: row.pastureid,
  2324. ftid: this.table2.getdataListParm.parammaps.ftid,
  2325. type: this.table2.getdataListParm.parammaps.fttypeid
  2326. }}
  2327. this.requestParam.data[3] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2328. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2329. id: this.table2.getdataListParm.parammaps.ftid
  2330. }}
  2331. }
  2332. ExecDataByConfig(this.requestParam).then(response => {
  2333. console.log('新增保存发送参数', this.requestParam)
  2334. if (response.msg === 'fail') {
  2335. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2336. } else {
  2337. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2338. this.getList2()
  2339. this.getList3()
  2340. }
  2341. })
  2342. }).catch(() => {
  2343. this.$message({ type: 'info', message: '已取消删除' })
  2344. })
  2345. },
  2346. handleSelectionChange2(val) {
  2347. console.log('勾选数据', val)
  2348. this.selectList2 = val
  2349. },
  2350. handleDelete2() {
  2351. console.log('点击了删除')
  2352. if (this.selectList2.length == 0) {
  2353. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2354. } else {
  2355. MessageBox.confirm('是否确认删除此信息?', {
  2356. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2357. }).then(() => {
  2358. console.log(this.table2.list.length - this.selectList2.length)
  2359. if (this.table2.list.length - this.selectList2.length > 0) {
  2360. this.requestParam.common = { 'returnmap': '0' }
  2361. this.requestParam.data = []
  2362. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2363. this.requestParam.data[0].children = []
  2364. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2365. id: '@insertSpotList.id',
  2366. pastureid: '@insertSpotList.pastureid'
  2367. }}
  2368. this.requestParam.data[1] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2369. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2370. id: this.table2.getdataListParm.parammaps.ftid
  2371. }}
  2372. } else {
  2373. this.requestParam.common = { 'returnmap': '0' }
  2374. this.requestParam.data = []
  2375. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2376. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2377. id: this.table2.getdataListParm.parammaps.ftid
  2378. }}
  2379. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2380. this.requestParam.data[1].children = []
  2381. this.requestParam.data[1].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2382. id: '@insertSpotList.id',
  2383. pastureid: '@insertSpotList.pastureid'
  2384. }}
  2385. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2386. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2387. id: this.table2.getdataListParm.parammaps.ftid
  2388. }}
  2389. }
  2390. ExecDataByConfig(this.requestParam).then(response => {
  2391. console.log('删除保存发送参数', this.requestParam)
  2392. if (response.msg === 'fail') {
  2393. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2394. } else {
  2395. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  2396. this.getList2()
  2397. this.getList3()
  2398. }
  2399. })
  2400. })
  2401. }
  2402. },
  2403. // 拆分预混料
  2404. handleSplitPremix(row) {
  2405. console.log('点击了拆分预混料')
  2406. MessageBox.confirm('是否确认拆分当前预混料?', {
  2407. confirmButtonText: '确认',
  2408. cancelButtonText: '取消',
  2409. type: 'warning'
  2410. }).then(() => {
  2411. this.requestParam.name = 'splitFTpre'
  2412. this.requestParam.parammaps = {}
  2413. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2414. this.requestParam.parammaps.preftid = row.preftid
  2415. this.requestParam.parammaps.ftdid = row.id
  2416. this.requestParam.parammaps.pastureid = row.pastureid
  2417. this.requestParam.parammaps.feedgroup = row.feedgroup
  2418. this.requestParam.parammaps.sort = row.sort
  2419. this.requestParam.parammaps.fweight = row.fweight
  2420. PostDataByName(this.requestParam).then(response => {
  2421. if (response.msg === 'fail') {
  2422. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2423. } else {
  2424. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2425. this.getList2()
  2426. this.getList3()
  2427. }
  2428. })
  2429. }).catch(() => {
  2430. this.$message({
  2431. type: 'info',
  2432. message: '已取消删除'
  2433. })
  2434. })
  2435. },
  2436. // 合成预混料
  2437. handleSyntheticPremix() {
  2438. console.log('点击了合成预混料', this.selectList2)
  2439. this.dialogFull = false
  2440. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2441. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2442. return false
  2443. } else {
  2444. if (this.selectList2.length > 1) {
  2445. for (let i = 0; i < this.selectList2.length; i++) {
  2446. if (parseInt(this.selectList2[i].preftid) > 0) {
  2447. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2448. return false
  2449. }
  2450. }
  2451. if (this.selectList2[0].splitftpreid !== undefined) {
  2452. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2453. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2454. GetDataByName(this.detail.getdataListParm).then(response => {
  2455. if (response.data.list !== null) { // 不为空时得到比对数据
  2456. this.detail.list3 = response.data.list
  2457. const sortList = [] // 声明排序数组
  2458. var fweightSum = 0 // 总重量
  2459. for (let i = 0; i < this.selectList2.length; i++) {
  2460. const obj = {}
  2461. obj.fid = this.selectList2[i].fid
  2462. obj.fweight = this.selectList2[i].fweight
  2463. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2464. sortList.push(obj)
  2465. }
  2466. // 排序
  2467. sortList.sort(function(a, b) {
  2468. return a.fid.localeCompare(b.fid)
  2469. })
  2470. var a = 0
  2471. if (this.detail.list3.length == sortList.length) {
  2472. for (let i = 0; i < this.detail.list3.length; i++) {
  2473. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(parseInt(Cookies.get('decimal'))) == (sortList[i].fweight / fweightSum).toFixed(parseInt(Cookies.get('decimal')))) {
  2474. a++
  2475. }
  2476. }
  2477. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2478. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2479. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2480. GetDataByName(this.detail.getdataListParm2).then(response => {
  2481. if (response.data.list !== null) {
  2482. this.detail.dialogStatus = 'SyntheticPremix'
  2483. this.detail.dialogFormVisible = true
  2484. this.detail.list = this.selectList2
  2485. this.detail.list2 = response.data.list
  2486. this.detail.disabled = true
  2487. setTimeout(() => {
  2488. this.detail.listLoading = false
  2489. }, 100)
  2490. } else {
  2491. this.detail.list2 = []
  2492. }
  2493. })
  2494. } else {
  2495. this.detail.dialogStatus = 'SyntheticPremix'
  2496. this.detail.dialogFormVisible = true
  2497. this.detail.list = this.selectList2
  2498. this.detail.disabled = false
  2499. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2500. setTimeout(() => {
  2501. this.detail.listLoading = false
  2502. }, 100)
  2503. }
  2504. } else {
  2505. this.detail.dialogStatus = 'SyntheticPremix'
  2506. this.detail.dialogFormVisible = true
  2507. this.detail.list = this.selectList2
  2508. this.detail.disabled = false
  2509. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2510. setTimeout(() => {
  2511. this.detail.listLoading = false
  2512. }, 100)
  2513. }
  2514. } else {
  2515. this.detail.list3 = []
  2516. this.detail.dialogStatus = 'SyntheticPremix'
  2517. this.detail.dialogFormVisible = true
  2518. this.detail.list = this.selectList2
  2519. this.detail.disabled = false
  2520. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2521. setTimeout(() => {
  2522. this.detail.listLoading = false
  2523. }, 100)
  2524. }
  2525. })
  2526. } else {
  2527. this.detail.dialogStatus = 'SyntheticPremix'
  2528. this.detail.dialogFormVisible = true
  2529. this.detail.list = this.selectList2
  2530. this.detail.disabled = false
  2531. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2532. setTimeout(() => {
  2533. this.detail.listLoading = false
  2534. }, 100)
  2535. }
  2536. } else {
  2537. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2538. return false
  2539. }
  2540. }
  2541. },
  2542. // 畜生类别
  2543. changeLivestockType2(item) {
  2544. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2545. },
  2546. syntheticPremixData() {
  2547. console.log('点击了合成预混料确认')
  2548. if (this.detail.disabled == true) { // 原预混料
  2549. let sumFweight = 0
  2550. for (let i = 0; i < this.detail.list.length; i++) {
  2551. sumFweight += parseFloat(this.detail.list[i].fweight)
  2552. }
  2553. sumFweight = sumFweight.toFixed(parseInt(Cookies.get('decimal')))
  2554. this.isokDisable = true
  2555. setTimeout(() => {
  2556. this.isokDisable = false
  2557. }, 1000)
  2558. this.requestParam.common = { 'returnmap': '0' }
  2559. this.requestParam.data = []
  2560. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2561. this.requestParam.data[0].children = []
  2562. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2563. pastureid: '@insertSpotList.pastureid',
  2564. id: '@insertSpotList.id'
  2565. }}
  2566. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2567. this.requestParam.data[1].children = []
  2568. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2569. pastureid: Cookies.get('pastureid'),
  2570. ftid: this.table2.getdataListParm.parammaps.ftid,
  2571. fid: this.detail.list2[0].id,
  2572. fname: '@insertSpotList2.tname',
  2573. fweight: sumFweight,
  2574. islockcount: '0',
  2575. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2576. feedgroup: '@insertSpotList2.tname',
  2577. preftid: this.detail.list2[0].id,
  2578. autosecond: this.detail.list[0].autosecond
  2579. }}
  2580. ExecDataByConfig(this.requestParam).then(response => {
  2581. console.log('合成预混料保存发送参数', this.requestParam)
  2582. if (response.msg === 'fail') {
  2583. const tname = new RegExp("key 'tname'")
  2584. if (tname.test(response.data)) {
  2585. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2586. } else {
  2587. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2588. }
  2589. } else {
  2590. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2591. this.detail.dialogFormVisible = false
  2592. this.getList3()
  2593. this.getList2()
  2594. this.getDownList()
  2595. }
  2596. })
  2597. } else { // 现生成预混料
  2598. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2599. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2600. return false
  2601. } else if (this.detail.list2[0].tname == '') {
  2602. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2603. return false
  2604. } else if (this.detail.list2[0].ccid == '') {
  2605. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2606. return false
  2607. }
  2608. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2609. if (pattern.test(this.detail.list2[0].tname)) {
  2610. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2611. return false
  2612. }
  2613. let sumFweight = 0
  2614. for (let i = 0; i < this.detail.list.length; i++) {
  2615. sumFweight += parseFloat(this.detail.list[i].fweight)
  2616. }
  2617. sumFweight = sumFweight.toFixed(parseInt(Cookies.get('decimal')))
  2618. console.log(sumFweight)
  2619. this.isokDisable = true
  2620. setTimeout(() => {
  2621. this.isokDisable = false
  2622. }, 1000)
  2623. if (this.detail.list2[0].tcolor == null) {
  2624. this.detail.list2[0].tcolor = '#CCCCCC'
  2625. }
  2626. this.requestParam.common = { 'returnmap': '0' }
  2627. this.requestParam.data = []
  2628. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2629. pastureid: Cookies.get('pastureid'),
  2630. tcode: this.detail.list2[0].tcode,
  2631. tname: this.detail.list2[0].tname,
  2632. tcolor: this.detail.list2[0].tcolor,
  2633. ccid: this.detail.list2[0].ccid,
  2634. ccname: this.detail.list2[0].ccname,
  2635. fttype: this.detail.list2[0].fttype,
  2636. fttypeid: this.detail.list2[0].fttypeid,
  2637. source: this.detail.list2[0].source,
  2638. remark: this.detail.list2[0].remark,
  2639. enable: this.detail.list2[0].enable
  2640. }}
  2641. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2642. this.requestParam.data[1].children = []
  2643. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2644. pastureid: '@insertSpotList.pastureid',
  2645. ftid: '@insertFT.LastInsertId',
  2646. fid: '@insertSpotList.fid',
  2647. fname: '@insertSpotList.fname',
  2648. fweight: '@insertSpotList.fweight',
  2649. islockcount: '@insertSpotList.islockcount',
  2650. sort: '@insertSpotList.sort',
  2651. feedgroup: '@insertSpotList.feedgroup',
  2652. preftid: '@insertSpotList.preftid',
  2653. autosecond: '@insertSpotList.autosecond'
  2654. }}
  2655. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2656. pastureid: '@insertSpotList.pastureid',
  2657. id: '@insertSpotList.id'
  2658. }}
  2659. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2660. this.requestParam.data[2].children = []
  2661. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2662. pastureid: Cookies.get('pastureid'),
  2663. ftid: this.table2.getdataListParm.parammaps.ftid,
  2664. fid: '@insertFT.LastInsertId',
  2665. fname: '@insertSpotList2.tname',
  2666. fweight: sumFweight,
  2667. islockcount: '0',
  2668. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2669. feedgroup: '@insertSpotList2.tname',
  2670. preftid: '@insertFT.LastInsertId',
  2671. autosecond: this.detail.list[0].autosecond
  2672. }}
  2673. ExecDataByConfig(this.requestParam).then(response => {
  2674. console.log('合成预混料保存发送参数', this.requestParam)
  2675. if (response.msg === 'fail') {
  2676. const tname = new RegExp("key 'tname'")
  2677. if (tname.test(response.data)) {
  2678. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2679. } else {
  2680. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2681. }
  2682. } else {
  2683. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2684. this.detail.dialogFormVisible = false
  2685. this.getList3()
  2686. this.getList2()
  2687. this.getDownList()
  2688. }
  2689. })
  2690. }
  2691. },
  2692. handleFormulationEvaluation(row) {
  2693. console.log(row)
  2694. // this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  2695. this.$router.push({
  2696. name: 'FormulationEvaluation',
  2697. params: {
  2698. tname: row.tname,
  2699. ftid: row.id,
  2700. pastureid: row.pastureid,
  2701. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  2702. inputDatetime: [new Date('startTime'), new Date('startTime')], // 日期后台待传
  2703. stopTime: parseTime(new Date(), '{y}-{m}-{d}')
  2704. }
  2705. })
  2706. }
  2707. }
  2708. }
  2709. </script>
  2710. <style lang="scss" scoped>
  2711. .search{margin-top:10px;}
  2712. .table{margin-top:5px;}
  2713. .table2{margin-top:10px;}
  2714. $width:350px;
  2715. $left:325px;
  2716. .selectInput{
  2717. position: relative;
  2718. display: inline-block;
  2719. .Input{width: $width;position: relative;}
  2720. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2721. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2722. .selectUl{
  2723. 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;
  2724. li{
  2725. 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;
  2726. a{float:left;width: 80px;}
  2727. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2728. }
  2729. }
  2730. }
  2731. .template{
  2732. background: #fff;
  2733. position: relative;
  2734. }
  2735. .detail{
  2736. background: #fff;
  2737. // position: fixed;
  2738. // bottom: 0;
  2739. // right:0;
  2740. // z-index: 3;
  2741. // width: calc(100% - 210px);
  2742. position: relative;
  2743. }
  2744. .templateDialog{
  2745. background: #fff;
  2746. position: relative;
  2747. }
  2748. .detailDialog{
  2749. background: #fff;
  2750. position: relative;
  2751. }
  2752. .hide{float: right;margin-right: 60px;}
  2753. </style>
  2754. <style>
  2755. .el-color-dropdown__main-wrapper{display: none !important;}
  2756. .el-color-dropdown__value{display: none !important;}
  2757. .el-color-dropdown__btns .el-button--text{display: none !important;}
  2758. </style>