6d05b28215322208419083d760aebd97954bfa47.svn-base 125 KB

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