35addaf834c3502763b15c40a2ceba2fc578fbf4.svn-base 118 KB

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